Hi Rashmi, I believe you are looking for PathHierarchyTokenizer, see https://lucene.apache.org/core/4_0_0/analyzers-common/org/apache/lucene/analysis/path/PathHierarchyTokenizer.html
Oleg 2014-11-14 17:53 GMT-05:00 rashmy1 <rashmy.appanerava...@siemens.com>: > Hello, > I'm trying to setup Solr for fetching hierarchical facets. > Please advice which of the below approaches should be followed for my > scenario. > *Scenario: > * > NonFic > Hist > HistBook1 > HistBook2 > Sci > Phy > Quantum > Pbook1 > Pbook2 > Thermodynamics > Pbook3 > Pbook4 > Chem > Cbook1 > Math > Mbook1 > Fic > Mystery > Mybook1 > Childrens > Chbook1 > Chbook2 > > *Sample document* > <doc> > name=Pbook1 > category=NonFic/Sci/Phy/Quantum > author=ABC > price=20.00 > <doc> > > *Requirements:* > -Show drill down facets > -If user searched for "*", the initial set of facets to be shown are > 'NonFic' and 'Fic' > -If user selects facet 'NonFic', we then show the facets 'Hist' and 'Sci' > only. > > *Option1:* > /Solr schema:/ > <field indexed="true" multiValued="true" name="category" required="true" > stored="true" type="string"/> > /Document supplied for indexing:/ > <doc> > name=Pbook1 > category=0/NonFic > category=1/NonFic/Sci > category=2/NonFic/Sci/Phy > category=3/NonFic/Sci/Phy/Quantum > category=0/Other (a book can belong to multiple categories) > author=ABC > price=20.00 > <doc> > With Option2, we can do a drill down facet query. > For example, if we give facet.prefix=NonFic/Sci/, the facet results are: > NonFic/Sci/Phy > NonFic/Sci/Chem > NonFic/Sci/Math > The only issue is that I have to take care of generating all possible path > information for 'category' > > *Option2:* > /Solr schema:/ > <fieldType class="solr.TextField" name="path"> > <analyzer type="index"> > <tokenizer class="solr.PathHierarchyTokenizerFactory" > delimiter="/"/> > </analyzer> > </fieldType> > <field indexed="true" multiValued="true" name="category" required="true" > stored="true" type="path"/> > /Document supplied for indexing:/ > <doc> > name=Pbook1 > category=NonFic/Sci/Phy/Quantum > author=ABC > price=20.00 > <doc> > With Option2, we can do facet query but it returns all possible combination > of paths. > For example, if we give facet.prefix=Fic, the facet results are: > Fic (3) > Fic/Mystery (1) > Fic/Childrens (2) > > > I'm looking to supply a doc with just a single entry (like > 'category=NonFic/Sci/Phy/Quantum' ) and be able to do a drill down query. > Is > there some existing Solr tokernizer which takes care of generating all > possibly combinations which indexing instead of having to generating them > as > part of <doc> creation? > > Thanks > > > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Hierarchical-faceting-tp4169263.html > Sent from the Solr - User mailing list archive at Nabble.com. >