opensearch-project / documentation-website

The documentation for OpenSearch, OpenSearch Dashboards, and their associated plugins.
https://opensearch.org/docs
Apache License 2.0
66 stars 447 forks source link

Faceted search [DOC] #2157

Open macrakis opened 1 year ago

macrakis commented 1 year ago

What do you want to do?

Tell us about your request. Provide a summary of the request and all versions that are affected.

Document the use of OpenSearch aggregation and filtering features in QDSL to support faceted search.

We show users how to construct the query to do the following: Search for "shirt" and return facet counts for all Colors and Sleeve Lengths. Extra credit: show the query for after a Color has been selected (showing all Color counts, but only Color=Red counts for other facets). Extra credit: construct query for the Exclude case.

What other resources are available? Provide links to related issues, POCs, steps for testing, etc.

Jon-AtAWS commented 1 year ago

Extra extra credit: Document hierarchical and multi-select faceting

Hierarchical faceting enables drill down through a hierarchy of attributes like country > region > city through the use of one or more fields, that encode the hierarchy through non-breaking characters. E.g. usa:west:san franciso. Users can search for values in the hierarchy or scope to sub-trees by using prefix queries. I've seen this done with a single field, or one field at each level of the hierarchy, depending on whether you want to summarize at the different levels of the tree. When displaying to the user, the code strips the prefix and just reports on the values

Country USA Canada Mexico ...

City San Francisco Mexico City Toronto ...

etc.

Multi-select faceting enables the selection of more than one attribute for a particular field. e.g. color: red and color: blue. The tricky bit is getting the facet counts for, e.g., color: green when you have red and blue selected. You generally run a non-filtered query when 1 facet is selected, and then combinations of queries, selecting subsets of the facets to get the other values, when multiple facet fields have selections.

We need good examples for this, with code.