Using BooleanQuery or write more indexes?

前端 未结 1 462
梦谈多话
梦谈多话 2021-01-28 01:29

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

1条回答
  •  孤街浪徒
    2021-01-28 02:20

    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?.)

    0 讨论(0)
提交回复
热议问题