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