Query analyzer confusion of multi-field containing keyword and analyzed

Hello All -

I've come upon a behavior which I don't like. If the fields searched by query_string include a keyword (unanalyzed) field in addition to an analyzed field, it seems the token-level analyzer won't omit symbols. Below is a Kibana Dev Tools Console example I tested with Elasticsearch 5.6.12 . We're in the midst of migrating to Elasticsearch 6 and I introduced this buggy behavior to our app when i disabled _all and turned on "all_fields": true by default (as part of our gradual migration). Is there a workaround for this that doesn't involve explicitly specifying only analyzed fields? I tried adding "analyzer": "standard" without success.

Thanks in advance,
- Luke

PUT example
{}

PUT /example/widget/1
{
    "name": "alpha beta"
}

# hits
GET /example/_search
{
  "query": {
    "query_string": {
      "default_operator": "AND", 
      "query": "alpha & beta", 
      "fields": ["name"]
    }
  }
}

# no hits!?
GET /example/_search
{
  "query": {
    "query_string": {
      "default_operator": "AND", 
      "query": "alpha & beta", 
      "fields": ["name", "name.keyword"]
    }
  }
}

Aha! I tested this locally with 6.4.1 and my test case works! I guess I'll have to tolerate this until we finish our migration to 6.x for these searches to return correct results.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.