Skip to content

Queries and unmapped fields #12016

@clintongormley

Description

@clintongormley

As discussed in #11806, different queries handle unmapped fields differently. The nested, has_child, has_parent, geo_*, and function_score query throw exceptions, while all of the others match no docs instead.

We need to make the behaviour uniform across queries.

The solution we came up with in FixItFriday is:

  • if a field doesn't exist in an index, then replace the query with a FieldNotFound query, which matches no documents
  • if explain is turned on, then the field_not_found query will be part of the output
  • if the strict_mappings is passed, then the request will throw a field not found exception instead.

This preserves the ease of use of, eg:

GET _search?name=john

without making search requests even more verbose, but makes debugging bad field names easy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions