Getting null in response (InMemoryConnection) in mock testing

I am trying to mock elasticsearch using NEST library in C#. In the response I am getting null. This is the code:

var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
            var settings = new ConnectionSettings(connectionPool, new InMemoryConnection());
            settings.DisableDirectStreaming();
            settings.DefaultIndex("person");

            var c = new ElasticClient(settings);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "user"
            };
            
            var indexResponse = c.IndexDocument(person);

            var searchResponse = c.Search<Person>(s => s.Index("person")
            .AllIndices()
            .AllTypes()
            .From(0)
            .Size(10)
            .Query(q => q
                 .Match(m => m
                    .Field(f => f.FirstName)
                    .Query("test")
                 )
            )
        );
            var people = searchResponse.Documents;

In the above code, I am getting zero in searchResponse.Documents.
searchResponse value is :
Valid NEST response built from a successful low level call on POST: /default/_search
Audit trail of this API call:

  • [1] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.0079783
    Request:
    {"from":0,"size":10,"query":{"match":{"field":"FirstName","query":"test"}}}
    Response:

Any help will be highly appreciated.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.