Home > Enterprise >  ElasticSearch query_string text search on long field
ElasticSearch query_string text search on long field

Time:05-08

With the following query

{
    "query": {
        "query_string": {
            "query": "james",
            "fields": ["briefdescription", "sonumber"]
        }
    }
}

I get "reason": "failed to create query: For input string: \"james\"",

The problem I think it's sonumber is a long field, and it fails to search "james" on that field, but if I just use default_field: "*", it doesn't throw the error. Why is that? Does default_field skips the incompatible types?

CodePudding user response:

Yes that's probably the reason, you can also alleviate this using the lenient parameter to ignore those errors:

{
    "query": {
        "query_string": {
            "query": "james",
            "fields": ["briefdescription", "sonumber"],
    -->     "lenient": true
        }
    }
}
  • Related