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

IB.
  • 1,019
  • 3
  • 13
  • 21
  • 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. – y0j0 Nov 01 '16 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. – IB. Nov 02 '16 at 08:18
  • http://prntscr.com/d23uux – y0j0 Nov 02 '16 at 12:32
  • Thanks @JozefCechovsky , had to set DisableDirectStreaming to true in the connectionsettings – IB. Nov 02 '16 at 14:35
  • yes you're right, I forgot to mention DisableDirectStreaming – y0j0 Nov 02 '16 at 15:58

1 Answers1

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"
}
Mic987
  • 188
  • 5
  • 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 – Russ Cam Nov 01 '16 at 21:03