You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by crocket <cr...@gmail.com> on 2013/04/01 07:04:44 UTC

Re: How do I retrieve a list of child categories for a category?

Well, I can understand the code easily, but it could have been very
difficult to find out without you since it is not explained in facet user
guide and I couldn't imagine TaxonomyReader was the key to this process.

It would have been a lot better if there had been a higher level API for
retrieving or traversing child categories.

What do you like to do regarding this?


On Sun, Mar 31, 2013 at 1:42 PM, Shai Erera <se...@gmail.com> wrote:

> 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 <cr...@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?
> >
>

Re: How do I retrieve a list of child categories for a category?

Posted by crocket <cr...@gmail.com>.
>Maybe we could add some simple sugar APIs?

>Eg something like Collection<CategoryPath> getChildren(int parentOrd)?
> (Or maybe it returns Iterator<CategoryPath>?)

>Mike McCandless

I think we should talk about this in apache jira.

I created an issue at https://issues.apache.org/jira/browse/LUCENE-4897

Re: How do I retrieve a list of child categories for a category?

Posted by Michael McCandless <lu...@mikemccandless.com>.
On Mon, Apr 1, 2013 at 1:04 AM, crocket <cr...@gmail.com> wrote:
> Well, I can understand the code easily, but it could have been very
> difficult to find out without you since it is not explained in facet user
> guide and I couldn't imagine TaxonomyReader was the key to this process.
>
> It would have been a lot better if there had been a higher level API for
> retrieving or traversing child categories.
>
> What do you like to do regarding this?

Maybe we could add some simple sugar APIs?

Eg something like Collection<CategoryPath> getChildren(int parentOrd)?
 (Or maybe it returns Iterator<CategoryPath>?)

Mike McCandless

http://blog.mikemccandless.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org