Oh and one more thing, I was Googling on this and found 
http://www.springyweb.com/2012/01/hierarchical-faceting-with-elastic.html, so 
apparently your solution is similar to this: hierarchical Faceting With Elastic 
Search?
So does your solution facilitate for items to be in multiple categories? e.g. a 
product may be in:

Man 
Man > top 
Man > top > shirt 
Man > top > shirt> sleeveless shirt 

AND also fall under:

Clothing 
Clothing > shirt 
Clothing > shirt> sleeveless shirt 

Thanks again! 

From: Alessandro Benedetti [via Lucene] 
Sent: Tuesday, July 28, 2015 10:26
To: PeterKerk 
Subject: Re: Use faceted search to drill down in hierarchical structure and 
omit node data outside current selection

The fact is that you are trying to model a hierarchical facet on documents 
that actually index the  content as a simple field. 

What I would suggest for example is to use a PathhierarcyTokenizer for your 
field with a proper separator. 
This will produce these tokens in the index : 

input : Man > top > shirt > sleeveless shirt 
Tokenized : 

Man 
Man > top 
Man > top > shirt 
Man > top > shirt> sleeveless shirt 

At this point your counting will be exactly what you would like, you need 
only to parse it Search API side and model the hierarchical facets in 
nested elements. 

Cheers 



2015-07-28 2:02 GMT+01:00 PeterKerk <[hidden email]>: 


> I have the following structure for my products, where a product may fall 
> into 
> multiple categories. In my case, a "caketopper", which would be under 
> "cake/caketoppers" as well as "caketoppers" (don't focus on the logic 
> behind 
> the category structure in this example). 
> 
> Category structure: 
> 
>         cake 
>                 caketoppers 
>                         funny 
> 
>         caketoppers 
>                 funny 
> 
> What I want is that when the user has chosen a category on level 0 (the 
> main 
> category selection), in this case 'caketoppers', I don't want to return the 
> attributes/values that same product has because it's also in a different 
> category. 
> I tried the following queries, but it keeps returning all data: 
> 
> 
> &f.slug_nl_0.facet.pre‌​fix=(caketoppers)&fq=slug_nl_0:"(caketoppers)" 
> 
> &f.slug_nl_0.facet.pre‌​fix="caketoppers"&fq=slug_nl_0:"(caketoppers)" 
> 
> I keep getting this result (cleaned for better readability): 
> 
>         <result name="response" numFound="6" start="0"> 
>                 <doc> 
>                         <arr name="slug_nl_0"> 
>                                 <str>caketoppers</str> 
>                                 <str>cake</str> 
>                         </arr> 
>                 </doc> 
>         </result> 
>         <lst name="facet_counts"> 
>                 <lst name="facet_fields"> 
>                         <lst name="slug_nl_0"> 
>                                 <int name="cake">6</int> 
>                                 <int name="caketoppers">6</int> 
>                         </lst> 
>                 </lst> 
>         </lst> 
> 
> But my desired result would be: 
> 
>         <result name="response" numFound="6" start="0"> 
>                 <doc> 
>                         <arr name="slug_nl_0"> 
>                                 <str>caketoppers</str> 
>                         </arr> 
>                 </doc> 
>         </result> 
>         <lst name="facet_counts"> 
>                 <lst name="facet_fields"> 
>                         <lst name="slug_nl_0"> 
>                                 <int name="caketoppers">6</int> 
>                         </lst> 
>                 </lst> 
>         </lst> 
> 
> 
> 
> field definition of 'slug_nl_0' in schema.xml: 
>     <field name="slug_nl_0" type="text" indexed="true" stored="true" 
> multiValued="true"/> 
> 
> 
> I also tried with a more simple query but I'm getting the exact same 
> results: 
> 
>         &facet.pre‌​fix=caketoppers&fq=slug_nl_0:caketoppers 
> 
> I then was reading into grouping: 
> http://wiki.apache.org/solr/FieldCollapsing
> 
> So I tried adding that in my queries, but I get errors: 
> 
> 
> `&fq=slug_nl_0:taarttoppers&group=true&group.facet=true&group.field=slug_nl_0`
>  
> 
> error: can not use FieldCache on multivalued field: slug_nl_0 
> 
> `&fq=slug_nl_0:taarttoppers&group=true&group.field=slug_nl_0` 
> 
> error: can not use FieldCache on multivalued field: slug_nl_0 
> 
> `&fq=slug_nl_0:taarttoppers&group.facet=true&group.field=slug_nl_0` 
> 
> error: Specify the group.field as parameter or local parameter 
> 
> And then I noticed this at the bottom of the page: 
> 
> > Known Limitations Support for grouping on a multi-valued field has not 
> > yet been implemented. 
> 
> On that same Solr FieldCollapsing example page they refer to Best Buy as an 
> example. Now I wonder how that was implemented without support for 
> multivalued fields. 
> 
> What can I do? 
> 
> 
> 
> 
> -- 
> View this message in context: 
> http://lucene.472066.n3.nabble.com/Use-faceted-search-to-drill-down-in-hierarchical-structure-and-omit-node-data-outside-current-selectn-tp4219384.html
> Sent from the Solr - User mailing list archive at Nabble.com. 
> 



-- 
-------------------------- 

Benedetti Alessandro 
Visiting card - http://about.me/alessandro_benedetti
Blog - http://alexbenedetti.blogspot.co.uk

"Tyger, tyger burning bright 
In the forests of the night, 
What immortal hand or eye 
Could frame thy fearful symmetry?" 

William Blake - Songs of Experience -1794 England 



--------------------------------------------------------------------------------

If you reply to this email, your message will be added to the discussion below:
http://lucene.472066.n3.nabble.com/Use-faceted-search-to-drill-down-in-hierarchical-structure-and-omit-node-data-outside-current-selectn-tp4219384p4219486.html
 
To unsubscribe from Use faceted search to drill down in hierarchical structure 
and omit node data outside current selection, click here.
NAML

wlEmoticon-smile[1].png (1K) 
<http://lucene.472066.n3.nabble.com/attachment/4219517/0/wlEmoticon-smile%5B1%5D.png>




--
View this message in context: 
http://lucene.472066.n3.nabble.com/Use-faceted-search-to-drill-down-in-hierarchical-structure-and-omit-node-data-outside-current-selectn-tp4219384p4219517.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to