Reputation: 1743
This is a weird question, but is it possible to have facets defined in ElasticSearch that don't have any documents associated with them? Like having a list of all possible facets even if they aren't all used.
Thanks!
Upvotes: 0
Views: 73
Reputation: 2762
I think I get what you're trying to do here. There is no way to have facet values without documents.
Probably stating the obvious, but I would store a document (preferably in a separate type or index or even just a good ole SQL table if you're old school) that has all the known possibilities. Then overlay that over your actual results.
It is worth noting, you can return empty facet buckets from queries with the "all_terms" option, but those values must exist in some document in your index.
This means you could also potentially have a dummy document that never gets returned by any queries to give the zero counts.
Upvotes: 1