Searching Elastic Search with low level client

Hi All,

I have just started with elastic search.
I am searching elasticsearch database, with low-level [Elasticsearch.Net]

(https://github.com/elasticsearch/elasticsearch-net/tree/master/src/Elasticsearch.Net) client.

I am using source query as lucene queries to extract records from elastic search database.

Here are some of my queries

  1. While searching with low level client, does it post anything to elastic search db, as in argument I see postdata as parameter passed?

//.LowLevel is of type IElasticLowLevelClient
// Generic parameter of Search<> is the type of .Body on response
var response = client.LowLevel.Search<SearchResponse>("myindex", PostData.Serializable(new

  1. Does using low level queries impact my search results ?
    I want to use lucene's query in body while searching and need to make sure I get upto date response.

I want to use lucene's queries to extract data from elastic search, which is best feasbile option?
I see we can use NEST powerful DSL, but i have limited knowledge in creating NEST queries.

3.) How to deal with huge response?
Currently response is stored it in StringResponse and need to handle huge responses as well.
Stringresponse strResponse= esClient.LowLevel.Search(Of StringResponse)(argin_strIndex01,argin_strQuery)

Thanks.

Let me see if I can answer your questions

The .NET client does not send request bodies with HTTP GET requests as they are not supported by the underlying HTTP library used, so whenever a request will send a body using PostData, the request will always be a HTTP POST (or a PUT, depending on the operation).

For example, using the low level client exposed on NEST 7.x, the high level client

var client = new ElasticClient();

var searchResponse = client.LowLevel.Search<StringResponse>(PostData.Serializable(new 
{
    query = new 
    {
        query_string = new 
        {
            default_field = "content",
            // Lucene query
            query = "this AND that OR thus"
        }    
    }
}));

results in the following query string query

POST http://localhost:9200/_search
{"query":{"query_string":{"default_field":"content","query":"this AND that OR thus"}}}

You can use the low level or high level client, it's up to you. The difference between them is that the latter has types for all requests and responses. and documents can be modelled with Plain Old CLR Objects (POCOs), making it easier to develop with.

You should look at paginating or scrolling responses (and search_after, for some scenarios).

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