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 <petervdk...@hotmail.com>:

> 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

Reply via email to