Skip to content

Query DSL: Add different execution models for terms filter #1568

Closed
@kimchy

Description

@kimchy

The way terms filter currently executes is by iterating over the terms provided and finding matches docs (loading into a bitset) and caching it. Sometimes, we want a different execution model that can still be achieved by building more complex queries in the DSL, but would be nice to support them in the more compact model that terms filter provides.

The execution option now has the following options :

  • plain: The default. Works as today. Iterates over all the terms, building a bit set matching it, and filtering. The total filter is cached (keyed by the terms).
  • bool: Builds a bool filter wrapping each term in a term filter that is cached. The bool filter is optimized in this case since it bitwise or's the different term filter bitsets. The total filter is not cached by default in this case.
  • and: Builds an and filter wrapping each term in term filter that is cached. The total filter is not cached by default in this case. Most times, bool should be used as its faster thanks to its bitwise execution.

The "total" terms filter caching can still be explicitly controlled using the _cache option. Note the default value for it depends on the execution value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions