Get complete list of facet values (even when not in the result set), with doc_count=0
tfrancart opened this issue · comments
Very useful library, I love it.
Is there an option in the configuration to always return the full set of values for an aggregation, even for values that do not correspond to any item in the result set, with doc_count set to 0 ?
Or is there a workaround for this ? (I can retrieve the complete list of values for an aggregation by triggering an empty search, but it would be much more convenient in my situation to consistently retrieve complete list of values to update the view with all values, and set colors/icons according to if the value is selected and if it has some results).
Cheers
@tfrancart thanks for a feedback!
Returning the complete list of values even if the doc_count is 0 might be a good feature as a new configuration option. Feel free to make a PR.
Right now workaround like triggering an empty search to get all filters seems best
Hi, thanks for the answer. Unfortunately I don't have the Javascript skills nor the bandwith to contribute directly to the code.
Maybe you could point to the exact place in lib.js where the modification should take place ?
I'd be also happy to test any improvement, and contribute to documentation on that new parameter.
This .buckets
function is responsible for returning values in filters behavior:
Line 277 in f19850f
Please let's try conjunction: false
in filters as in example (https://github.com/itemsapi/itemsjs/blob/master/docs/configuration.md). Probably that is what you are looking for.
Thanks for coming back to me on this
Please let's try conjunction: false in filters as in example (https://github.com/itemsapi/itemsjs/blob/master/docs/configuration.md). Probably that is what you are looking for.
This is not quite what I am looking for. With conjunction: false
, I always get the same values in the aggregation, with the same doc_count, independantly of the current result set. I think this really means : "this facet should be interpreted as an OR, so the user should be able to select multiple values from it, including values that are outside of the current result set, so let's always return the complete list of values, with total doc_count".
I need the same thing, but with the doc_count
updated with respect to the current result set. I don't know if this could be an update of the existing conjunction: false
flag, or if this requires a separate option.
Hey @tfrancart, this issue has been resolved in the new version 2.0.0. All filters are listed now even if positive number or 0. You can test it out here https://jsfiddle.net/cigol/0ef9qeos/181.
If that's still not working properly please reopen