Skip to content

{"query_string":{"query":"_exists_:(foo bar)"}} default operator behavior is different between 2.4.4 and 6.2.3 #31297

Closed
@bczifra

Description

@bczifra

Elasticsearch version (bin/elasticsearch --version): 6.2.3

Plugins installed: x-pack

JVM version (java -version): 1.8.0_91

OS version (uname -a if on a Unix-like system): macOS 10.12.5

Description of the problem including expected versus actual behavior:
{"query_string":{"query":"_exists_:(foo bar)"}} used to match if a document had either field foo or field bar. Now it tries to match a field named foo bar instead.

Steps to reproduce:

POST exists/doc/1
{
  "foo": "bar"
}

#matches in 2.4.4, no match in 6.2.3
GET exists/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "_exists_:(foo bar)"
          }
        }
      ]
    }
  }
}

#matches in both
GET exists/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "_exists_:(foo OR bar)"
          }
        }
      ]
    }
  }
}

#matches in 2.4.4, no match in 6.2.3
GET exists/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "_exists_:(foo bar)",
            "default_operator": "OR"
          }
        }
      ]
    }
  }
}

It appears that this might have changed in 6.1.
Using the explain API indicates that this is how the query is treated across the various versions:

  • 2.4: +(ConstantScore(ConstantScore(_field_names:foo)) ConstantScore(ConstantScore(_field_names:bar)))
  • 5.x: +(ConstantScore(_field_names:foo) ConstantScore(_field_names:bar))
  • 6.x: ConstantScore(DocValuesFieldExistsQuery [field=foo bar])

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions