Skip to content

Add support for minimum_should_match to aggregations #51

@renatonascalves

Description

@renatonascalves

Description

We need a method to be able to include all items in an aggregation, even if no results match those items, as an opt-in feature.

For example, we should have a way of being able to run elasticsearch_extensions()->get_aggregation_by_query_var( 'taxonomy_custom' )->checkboxes() and have checkboxes show for all items in the aggregation, even if none of the results match (e.g., show all categories, even if no posts are in a particular category in the results).

Use Case

A site needs to show an aggregation but listing all the aggregation items available.

Acceptance Criteria

  • Allow an aggregation to be registered with an optional property of the minimum number of items to match in order for the aggregation item to show. This could be set to 0 to show items that don't have any matches (e.g., a category that doesn't have any matches in the results) or a higher number to only show items that have many matches (e.g., 10 to exclude the long tail of matches).

Comments

This will likely need to be done as a combination of Elasticsearch queries and WordPress database queries, because Elasticsearch won't know about items that are empty (e.g., taxonomy terms that aren't assigned to anything).

Metadata

Metadata

Labels

elasticsearchRequires understanding ElasticsearchenhancementNew feature or requestphpRequires understanding PHP

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions