0

I am working with elasticsearch 2.3.4 (can update to 5 but its still 1 week since release and waiting for reviews on how its working)

I am trying to create asearch within my .net class

ISearchResponse<ClassModel> apiResponse = client1.Search<ClassModel>(a =>
            a.Query(q =>
            q.Term(p => p.param1, Param1) &&
            q.Term(p => p.const1, "const1") &&
            q.Term(p => p.param2, param2)));

For some reason the const1 return no values (even if i run it alone without the other params) but with HD extension i get results, maybe i shouldnt use Term ? something else?

Thank you in advance

5
  • Did you try to look at debug info in your apiReponse? There you can see query generated by NEST and you can check if the query is correct. Commented Nov 1, 2016 at 15:14
  • @JozefCechovsky can you please tell me where i find the query generated by NEST ? i checked and couldnt find it, indeed that would be very helpful. Commented Nov 2, 2016 at 8:18
  • prntscr.com/d23uux Commented Nov 2, 2016 at 12:32
  • Thanks @JozefCechovsky , had to set DisableDirectStreaming to true in the connectionsettings Commented Nov 2, 2016 at 14:35
  • yes you're right, I forgot to mention DisableDirectStreaming Commented Nov 2, 2016 at 15:58

1 Answer 1

1

It sounds as though you might not have the correct mapping on the "const1" field.

Edit as per comment below: You can use a term query on an analyzed field but it's unlikely to work how you might expect. If your field "const1" contains multiple words, then a term query with search text equal to the string you indexed will not match.

"const1": {
    "type":     "string",
    "index":    "not_analyzed"
}
Sign up to request clarification or add additional context in comments.

1 Comment

A term query doesn't need the field to be not_analyzed; you can run it on an analyzed field, you just need to be aware that the term query does not analyze the input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.