3
votes

We have an Elastic Search structure that specifies fields in a multi_match query like this:

"multi_match": {
                            "query": "find this string",
                            "fields": ["*_id^20", "*_name^20", "*"]
                        }

This works great - except under certain circumstances like when query is "Find NOWAK". This is because "NOW" is a reserved word for date searching and field "*" matches fields that are defined as dates.

So what I would like to do is ignore fields that match "*_at".

Is there way to tell Elastic Search to ignore certain fields in a multi_match query?

If the answer to that is "no" then the follow up question is how to escape the search term so that it won't trigger key words

Running version 6.7

2
@user7594840 The recommend approach in that answer is to explicitly white-list fields. That would be very maintenance intensive for my use-case, The fields list in my documents can grow over time, but only two fields will ever by ignored.ChronoFish

2 Answers

0
votes

Try this:

Exclude a field on a Elasticsearch query

curl -XGET 'localhost:9200/testidx/items/_search?pretty=true' -d '{
  "query" : {
     "query_string": {
          "fields": ["title", "field2", "field3"],      <-- add this
          "query": "Titulo"
     }},
     "_source" : {
          "exclude" : ["*.body"]
     }
}'
0
votes

Apparently the answer is "No: there is not a way to tell ElasticSearch to ignore certain fields in a multi_match query"

For my particular issue I found an inexpensive way to find the necessary white-listed fields (this is performed outside the scope of ElasticSearch otherwise I would post it here) and list those in place of the "*" when building the query.

I am hopeful someone will tell me I'm wrong, but I don't think I am.