lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Re: How do I retrieve a list of child categories for a category?
Date Sun, 31 Mar 2013 04:42:05 GMT
Hi

You can do so quite easily, using TaxonomyReader, following code such as:

ParallelTaxonomyArrays arrays = taxoReader.getParallelTaxonomyArrays();
int[] children = arrays.children();
int[] siblings = arrays.siblings();

int ordinal = taxoReader.getOrdinal(category); // ordinal of requested
category
int child = children[ordinal]; // child of requested category
int sibling = siblings[child]; // siblings[] lets you traverse the children
of a category
while (sibling != TaxonomyReader.INVALID_ORDINAL) {
  System.out.println(taxoReader.getPath(sibling));
  sibling = siblings[sibling]; // get next sibling
}

Shai


On Sun, Mar 31, 2013 at 12:24 AM, crocket <crockabiscuit@gmail.com> wrote:

> I could use CountFacetRequest, but I don't need counting.
>
> I just want to get the list of child categories.
>
> How can I do it?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message