I'm trying to add testing around our use of ElasticSearch (in C# using Nest 1.4.2) and want to use InMemoryConnection but I'm missing something (I assume) and having no success.
I've created this simple Nunit test case as a boiled down example of my issue
using System;
using Elasticsearch.Net.Connection;
using FluentAssertions;
using Nest;
using NUnit.Framework;
namespace NestTest
{
public class InMemoryConnections
{
public class TestThing
{
public string Stuff { get; }
public TestThing(string stuff)
{
Stuff = stuff;
}
}
[Test]
public void CanBeQueried()
{
var connectionSettings = new ConnectionSettings(new Uri("http://foo.test"), "default_index");
var c = new ElasticClient(connectionSettings, new InMemoryConnection(connectionSettings));
c.Index(new TestThing("peter rabbit"));
var result = c.Search<TestThing>(sd => sd);
result.ConnectionStatus.Success.Should().BeTrue();
}
}
}
the query is successful but doesn't find the document I just indexed...
If I update to NEST version 2.3.3 and the new syntax
[Test]
public void CanBeQueried()
{
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(connectionPool, new InMemoryConnection());
settings.DefaultIndex("default");
var c = new ElasticClient(settings);
c.Index(new TestThing("peter rabbit"));
var result = c.Search<TestThing>(sd => sd);
result.CallDetails.Success.Should().BeTrue();
result.Documents.Single().Stuff.Should().Be("peter rabbit");
}
it fails in the same way... i.e. the query is reported as successful but returns 0 documents