2021年1月1日星期五

Multi term search not giving results

Using elasticsearch 7.1.0 I have objects like this:

{  ... other fields  "entityId": "abcdef",  "anotherParameter": "something@weird-here"  }  

I need to make an exact match on both entityId and anotherParameter (case can be ignored). I use this query via the NEST library in C#

GET objects/_search  {      "from": 0,      "query": {          "bool": {              "filter": [                  {                      "bool": {                          "must": [                              {                                  "term": {                                      "entityId": {                                          "value": "abcdef"                                      }                                  }                              },                              {                                  "term": {                                      "anotherParameter": {                                          "value": "something@weird-here"                                      }                                  }                              }                          ]                      }                  }              ]          }      }  }  

Which does not return anything. Mappings for both fields is:

"type" : "text",            "fields" : {              "keyword" : {                "type" : "keyword",                "ignore_above" : 256              }            }  

If I leave out the @ and just put in "something" in the anotherParameter field, I get the right objects but also stuff that I don't want returned. I'm looking for directions on how to do the exact search. Anyone?

https://stackoverflow.com/questions/65534220/multi-term-search-not-giving-results January 02, 2021 at 06:23AM

没有评论:

发表评论