elasticsearchnestsenseelasticsearch-net

ElasticSearch NEST Query


I'm trying to mimic a query that I wrote in Sense (chrome plugin) using NEST in C#. I can't figure out what the difference between the two queries is. The Sense query returns records while the nest query does not. The queries are as follows:

var searchResults = client.Search<File>(s => s.Query(q => q.Term(p => p.fileContents, "int")));

and

{
"query": {
    "term": {
       "fileContents": {
          "value": "int"
       }
    }
}

What is the difference between these two queries? Why would one return records and the other not?


Solution

  • You can find out what query NEST uses with the following code:

    var json = System.Text.Encoding.UTF8.GetString(searchResults.RequestInformation.Request);
    

    Then you can compare the output.