Add support for multi-select facets #1329
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Disclaimer: names for these concepts are up for discussion.
Add support for multi-select facets. Normally rendered as check boxes in an interface.
The selected facets from the group are OR-ed.
Make a facet group multi-select by setting
connective
(as in "logical connective") toOR
in_statsrepr
Example
Normally configured in https://github.com/libris/definitions/blob/develop/source/apps.jsonld
In the search response the facet (observation) is marked as
selected: true/false
and theview
-link selects/deselects the facet.Example: Collection and Integrating are selected.
The only change needed to the client is to render facets as checkboxes when the
selected
property is present.Changes
We've of course always supported filtering on multiple values for the same property. That is in fact the default behavior.
The big changes are in how document counts in facets have to be performed.
ES aggregations are calculated on the query result. We now want to have counts on documents that are outside the result set. For example, when "Serial" is selected we should still show the number of documents with "Monograph". Before this change filters were always applied in the
filter
section of thequery
. Multi-select facets/filters have now been moved topost_filter
[1] which is run after aggregations. This means we still correct result set in the end.Since multi-facet filters are applied after aggregation we now have to do some filtering inside the aggregations to get the right count. This is done by moving applying the same filters as in
post_filter
to each aggregation. Except any filter that refers to the same field.Elastic is supposedly good at caching filter conditions so this should be efficient.
[1] https://www.elastic.co/guide/en/elasticsearch/reference/current/filter-search-results.html#post-filter
Example
Serial and Monograph are selected
same filter on other aggs, for instance
meta.bibliography.@id
.a
is just a dummy name for the nested agg.but not on
issuanceType
aggFuture
This works, but we are reaching the point where the query building has to be refactored. For example not passing around
queryParameters
everywhere but parse everything into a better representation of the state and requested query.