A category tree like this:
root_1
sub_1
sub_2
... to sub_20
Every document has a sub category(like sub_2
). Now, I only wrot
I would use a path enumeration/'Dewey Decimal' representation of the category hierarchy. That is, instead of just storing 'sub_2' for the second child of the first root, store instead something like '001.002'.
To find the root and all of its children, you would search on "category:001*".
To find only the children of the root, you would search on "category:001.*".
(Please also see How to store tree data in a Lucene/Solr/Elasticsearch index or a NoSQL db?.)