Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7902813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:35:58+00:00 2026-06-03T09:35:58+00:00

A category tree like this: root_1 sub_1 sub_2 … to sub_20 Every document has

  • 0

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 wrote sub_2 in lucene index:

new NumericField("category",...).setIntValue(sub_2.getID());

I want to get all root_1‘s documents, using BooleanQuery (merge the sub_1 to sub_20) to search or write an other category in every entry document:

new NumericField("category",...).setIntValue(sub_2.getID());
new NumericField("category",...).setIntValue(root_1.getID());//sub_2's ancestor category

Which is the better choice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:35:59+00:00Added an answer on June 3, 2026 at 9:35 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a category tree and i'd like to get all products that are
I have category model that has a tree structure. In my database I have
I have a left tree. Its structure is like this MainCategory Category1 Subcategory1 Subcategory2
I have a table that looks like this: category category_id name category_seo_friendly_url left_id right_id
I have a database that looks like this: I can generate a tree from
How to retrieve the value of type in the below XML <info><category>Flip</category><info>2</info><type>Tree</type></info>
I have a tree-like object structure that consists of two types of objects: object
I have a web application with a category tree that is published on the
I have the following table: CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category]
I have a tree like structure of Categories, the leaf Nodes in the tree

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.