elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.21k stars 24.85k forks source link

give an option to turn a unsupported field exception to a warning #99522

Open mumutu66 opened 1 year ago

mumutu66 commented 1 year ago

Description

In my case term search with a keyword with case_insensitive key is ok, but if the field switch to a long or anything else except keyword, I got an error case_insensitive is not supported and the query is failed. if an option to turn this exception to a warning is really useful for some general template query case, which can avoid to change the code with the field type changed

astefan commented 1 year ago

@mumutu66 can you provide a reproduceable set of steps that show the behavior you mentioned?

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-search (Team:Search)

mumutu66 commented 1 year ago

sorry for the late reply, the case is simple if a index has a mapping field with type long,when term query with case_insensitive will got error

in following example check_user_id is a long type


{
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "check_user_id": {
                  "value": 123123,
                  "case_insensitive": true
                }
              }
            },
            {
              "exists": {
                "field": "create_time"
              }
            }
          ]
        }
      }
    }
  },
  "_source": false,
  "size": 0,
  "stored_fields": "_none_",
  "track_total_hits": true
}

then I got a error


"reason": "[check_user_id] field which is of type [long], does not support case insensitive term queries",

I know this option case_insensitive is not suitable for a long type field, but I prefer a warning instead of error..or some hint to change some option in es to avoid the failure

elasticsearchmachine commented 4 months ago

Pinging @elastic/es-search-relevance (Team:Search Relevance)