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?
You can find out what query NEST uses with the following code:
Then you can compare the output.
I prefer this slightly simpler version, which I usually just type in .NET Immediate window:
Besides being shorter, it also gives the url, which can be quite helpful.
Try this:
client.Search() takes
Func<SearchDescriptor<T>, ISearchRequest>
as input (parameter).My answer from a similar post:
And got the deserialized JSON like this:
It was annoying, NEST library should have something that spits out the JSON from request. However this worked for me:
NEST library version: 2.0.0.0. Newer version may have an easier method to get this (Hopefully).