Querying on a field that does not exist will return results

When querying on a property that does not exist in ES 6.4 I notice that documents are returned despite the fact it is not in the mappings. See the below example. The name property exists however aklsdfkljasdf does not exist in the mappings. The query below will return any document matching with a name of user-login and it acts like the aklsdfkljasdf portion of the query is not evaluated.

I would expect this to return no results as the property does not exist. Looking for some assistance to understand why this is the case.

POST /myindexname/_search 
{
  "version": true,
  "size": 500,
  "_source": {
    "excludes": []
  },
  "stored_fields": [
    "*"
  ],
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "+name:(\"user-login\") +aklsdfkljasdf:(\"asdf\")",
            "analyze_wildcard": true,
            "default_field": "*"
          }
        }
      ]
    }
  }
}

Results

I tried this quickly and couldn’t reproduce (admittedly on 6.6).
Can you share a minimal reproduction (mapping, doc and query)?

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