Skip to content

TermQueryBuilder and WildcardQueryBuilder should rewrite queries on _index so that shards get skipped #48473

@jpountz

Description

@jpountz

term and wildcard queries already create either a MatchAllDocsQuery or a MatchNoDocsQuery at the shard level depending on the index name and its aliases. See IndexFieldType#termQuery and IndexFieldType#wildcardQuery for details.

It would be nice to go further and handle these in TermQueryBuilder#rewrite and WildcardQueryBuilder#rewrite. The benefit is that if someone queries index foo with a filter on { "term": { "_index": "bar" } }, then the top-level query will rewrite to a MatchNoDocsQuery, which is exactly the information that the can_match phase leverages in order to skip shards.

It would be a convenient and efficient way for Kibana to filter on a subset of data streams that are configured in the index patterns.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions