>I'm looking to see if Solr has any in-built tokenizer that splits the
tokens
>and prepends with the depth information. I'd like to avoid building depth
>information into the filed values if Solr already has something that can be
>used.

So the goal is to find out the level of the tree for each category? You
could determine this in the UI by splitting the category facet value string
by the separator.

As you're aware, when you query a field indexed using
solr.PathHierarchyTokenizerFactory
you still get the full path category path back as a facet value.

For example, if a user navigates to "Phy":
fq={!term f=category}NonFic/Sci/Phy

The facet values that are returned will look like this (made up counts):

<lst name="category">
  <int name="NonFic/Sci/Phy">10</int>
  <int name="NonFic/Sci/Phy/Quantum>10</int>
</lst>

You could find out the level by doing .split("/").length on each value.

ECP

On Mon, Nov 17, 2014 at 9:25 PM, Jason Hellman <jhellman.innov...@gmail.com>
wrote:

> I realize you want to avoid putting depth details into the field values,
> but something has to imply the depth.  So with that in mind, here is
> another approach (with the assumption that you are chasing down a single
> branch of a tree (and all its subbranch offshoots)),
>
> Use dynamic fields
> Step from one level to the next with a simple increment
> Build the facet for the next level on the call
> The UI needs only know the current level
>
> This would possibly be as so:
>
> step_fieldname_n
>
> With a dynamic field configuration of:
>
> step_*
>
> The content of the step_fieldname_n field would either be the strong of
> the field value or the delimited path of the current level (as suited to
> taste).  Either way, most likely a fieldType of String (or some variation
> thereof)
>
> The UI would then call:
>
> facet.field=step_fieldname_n+1
>
> And the UI would need to be aware to carry the n+1 into the fq link
> verbiage:
>
> fq=step_fieldname_n+1:facetvalue
>
> The trick of all of this is that you must build your index with the depth
> of your hierarchy in mind to place the values into the suitable fields.
> You could, of course, write an UpdateProcessor to accomplish this if that
> seems fitting.
>
> Jason
>
> > On Nov 17, 2014, at 12:22 PM, Alexandre Rafalovitch <arafa...@gmail.com>
> wrote:
> >
> > You might be able to stick in a couple of PatternReplaceFilterFactory
> > in a row with regular expressions to catch different levels.
> >
> > Something like:
> >
> > <filter class="solr.PatternReplaceFilterFactory"
> > pattern="^[^0-9][^/]+/[^/]/[^/]+$" replacement="2$0" />
> > <filter class="solr.PatternReplaceFilterFactory"
> > pattern="^[^0-9][^/]+/[^/]$" replacement="1$0" />
> > ...
> >
> > I did not test this, you may need to escape some thing or put explicit
> > groups in there.
> >
> > Regards,
> >   Alex.
> > P.s.
> http://www.solr-start.com/javadoc/solr-lucene/org/apache/lucene/analysis/pattern/PatternReplaceFilterFactory.html
> >
> > Personal: http://www.outerthoughts.com/ and @arafalov
> > Solr resources and newsletter: http://www.solr-start.com/ and @solrstart
> > Solr popularizers community: https://www.linkedin.com/groups?gid=6713853
> >
> >
> > On 17 November 2014 15:01, rashmy1 <rashmy.appanerava...@siemens.com>
> wrote:
> >> Hi Alexandre,
> >> Yes, I've read this post and that's the 'Option1' listed in my initial
> post.
> >>
> >> I'm looking to see if Solr has any in-built tokenizer that splits the
> tokens
> >> and prepends with the depth information. I'd like to avoid building
> depth
> >> information into the filed values if Solr already has something that
> can be
> >> used.
> >>
> >> Thanks!
> >>
> >>
> >>
> >> --
> >> View this message in context:
> http://lucene.472066.n3.nabble.com/Hierarchical-faceting-tp4169263p4169536.html
> >> Sent from the Solr - User mailing list archive at Nabble.com.
>
>

Reply via email to