Matchphrase Query Elastic Search not working as expected

时间:2017-12-18 07:21:45

标签: elasticsearch nest

I have document containing field category and title and some other fields stored in elastic db. I need to search a phrase in title field of document but I do not get the document.
below is c# code I used

sd = new SearchDescriptor();

sd.Query(q =>  
 q.MatchPhrase(m => m
  .Field(p => p.title)
  .Query("Test Article in Credit")  
  ));

There is a document having title(fieldname) as "Test Article in Credit" but I do get 2 document but actually there are 5.

If I use match phrase in different field it does work but in above field it is not giving me desired result.

I took out the raw json from above nest query by serializing to memory stream. The raw json looked as below

{  
  "query": {  
  "match_phrase": {  
      "title": {  
        "query": "Test Article in Credit"  
       }  
    }  
  }  
}  

If I use the above raw query it gave me 5 documents but if i do nest query it gives me 2 documents.

I am not sure what i am missing.

0 个答案:

没有答案