You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by beaviebugeater <mb...@cox.net> on 2011/01/24 16:42:23 UTC

Faceting Question

I am attempting to do facets on products similar to how hayneedle does it on
their online stores (they do NOT use Solr).   See:
http://www.clockstyle.com/wall-clocks/antiqued/1359+1429+4294885075.cfm

So simple example, my left nav might contain categories and 2 attributes,
brand and capacity:

Categories
- Cat1 (23) selected
- Cat2 (16)
- Cat3 (5)

Brand
-Brand1 (18)
-Brand2 (10)
-Brand3 (0)

Capacity
-Capacity1 (14)
-Capacity2 (9)


Each category or attribute value is represented with a checkbox and can be
selected or deselected.

The initial entry into this page has one category selected.  Other
categories can be selected which might change the number of products related
to each attribute value.  The number of products in each category never
changes.

I should also be able to select one or more attribute.  

Logically this would look something like:

(Cat1 Or Cat2) AND (Value1 OR Value2) AND (Value4)

Behind the scenes I have each category and attribute value represented by a
"tag", which is just a numeric value.  So I search on the tags field only
and then facet on category, brand and capacity fields which are stored
separately.  

My current Solr query ends up looking something like:

&fq={!tag=tag1}tags:( |1003| |1007|) AND tags:(
|10015|)&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field={!ex=tag1}category&facet.field=capacity&facet.field=brand

This shows 2 categories being selected (1003 and 1007) and one attribute
value (10015). 

This partially works - the categories work fine.   The problem is, if I
select, say a brand attribute (as in the above example the 10015 tag) it
does filter to the selected categories AND the selected attribute BUT I'm
not able to broaden the search by selecting another attribute value.  

I want to display of products to be filtered to what I select, but I want to
be able to broaden the filter without having to back up.  

I feel like I'm close but still missing something.  Is there a way to
specify 2 tags that should be excluded from facet fields?

I hope this example makes sense.

Any help greatly appreciated.
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Faceting-Question-tp2320542p2320542.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Faceting Question

Posted by beaviebugeater <mb...@cox.net>.
Hmm, thanks for the response.  I'll play around with it and see if that
helps. 
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Faceting-Question-tp2320542p2321887.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Faceting Question

Posted by Geert-Jan Brits <gb...@gmail.com>.
> &fq={!tag=tag1}tags:( |1003| |1007|) AND tags:(
>|10015|)&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field={!ex=tag1}category&facet.field=capacity&facet.field=brand

I'm just guessing here, but perhaps {!tag=tag1} is only picking up the 'tags:(
|1003| |1007|) '-part. If so {!ex=tag1} would only exclude 'tags:( |1003|
|1007|) ' but it wouldn't exclude ' tags:(
|10015|)'

I believe this would 100% explain what you're seeing.

Assuming my guess is correct you could try to a couple of things (none of
which I'm absolutely certain will work, but you could try it out easily):
1. put fq in quotes: fq={!tag=tag1}"tags:( |1003| |1007|) AND tags:(|10015|)"
 --> this might instruct {!tag=tag1} to tag the whole fq-filter.
2. make multiple fq's, and exclude them all (not sure if you can exclude
multiple fields): fq={!tag=tag1}tags:( |1003| |1007|)&fq={!tag=tag2}tags:(
|10015|)&facet.field={!ex=tag1,tag2}category&...

hth,
Geert-Jan

2011/1/24 beaviebugeater <mb...@cox.net>

>
> I am attempting to do facets on products similar to how hayneedle does it
> on
> their online stores (they do NOT use Solr).   See:
> http://www.clockstyle.com/wall-clocks/antiqued/1359+1429+4294885075.cfm
>
> So simple example, my left nav might contain categories and 2 attributes,
> brand and capacity:
>
> Categories
> - Cat1 (23) selected
> - Cat2 (16)
> - Cat3 (5)
>
> Brand
> -Brand1 (18)
> -Brand2 (10)
> -Brand3 (0)
>
> Capacity
> -Capacity1 (14)
> -Capacity2 (9)
>
>
> Each category or attribute value is represented with a checkbox and can be
> selected or deselected.
>
> The initial entry into this page has one category selected.  Other
> categories can be selected which might change the number of products
> related
> to each attribute value.  The number of products in each category never
> changes.
>
> I should also be able to select one or more attribute.
>
> Logically this would look something like:
>
> (Cat1 Or Cat2) AND (Value1 OR Value2) AND (Value4)
>
> Behind the scenes I have each category and attribute value represented by a
> "tag", which is just a numeric value.  So I search on the tags field only
> and then facet on category, brand and capacity fields which are stored
> separately.
>
> My current Solr query ends up looking something like:
>
> &fq={!tag=tag1}tags:( |1003| |1007|) AND tags:(
>
> |10015|)&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field={!ex=tag1}category&facet.field=capacity&facet.field=brand
>
> This shows 2 categories being selected (1003 and 1007) and one attribute
> value (10015).
>
> This partially works - the categories work fine.   The problem is, if I
> select, say a brand attribute (as in the above example the 10015 tag) it
> does filter to the selected categories AND the selected attribute BUT I'm
> not able to broaden the search by selecting another attribute value.
>
> I want to display of products to be filtered to what I select, but I want
> to
> be able to broaden the filter without having to back up.
>
> I feel like I'm close but still missing something.  Is there a way to
> specify 2 tags that should be excluded from facet fields?
>
> I hope this example makes sense.
>
> Any help greatly appreciated.
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Faceting-Question-tp2320542p2320542.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>