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 cwhi <ch...@gmail.com> on 2014/10/07 17:22:35 UTC

Having an issue with pivot faceting

I'm having an issue getting pivot faceting working as expected.  I'm trying
to filter by a specific criteria, and then first facet by one of my document
attributes called item_generator, then facet those results into 2 sets each:
the first set is the count of documents satisfying that facet with
number_of_items_generated set to 0, the other set counting the documents
satisfying that facet with number_of_items_generated greater than 0.  Seems
simple enough, and it seems like pivot faceting with facet.interval.set
would be the solution.  However, I'm not getting the expected results.  Here
are my request and response:

Request:

http://localhost/solr/select/?facet=true&facet.sort=true&q=item_type:Food&facet.field=item_generator&f.number_of_items_generated.facet.interval.set=[0,0]&f.number_of_items_generated.facet.interval.set=[1,100]&rows=0&version=2.2&wt=json

Response:

{"responseHeader":{"status":0,"QTime":0,"params":{"f.number_of_items_generated.facet.interval.set":["[0,0]","[1,100]"],"facet":"true","facet.sort":"true","q”:"item_type:Food","facet.field”:"item_generator","wt":"json","version":"2.2","rows":"0"}},"response":{"numFound":743,"start":0,"docs":[]},"facet_counts":{"facet_queries":{},"facet_fields":{“item_generator":[“food-creator",387,”toy-creator",356]},"facet_dates":{},"facet_ranges":{}}}

I've set docValues="true" for number_of_items_generated in my schema.xml.
What am I doing wrong in my query?



--
View this message in context: http://lucene.472066.n3.nabble.com/Having-an-issue-with-pivot-faceting-tp4163158.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Having an issue with pivot faceting

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Having an issue with pivot faceting

Ok - first off -- your example request doens't include any "facet.pivot" 
params, so you aren't using pivot faceting .. which makes me concerned 
that if you aren't using the feature you think you are, or don't 
understand the feature you are using.

: I'm having an issue getting pivot faceting working as expected.  I'm trying
: to filter by a specific criteria, and then first facet by one of my document
: attributes called item_generator, then facet those results into 2 sets each:
: the first set is the count of documents satisfying that facet with
: number_of_items_generated set to 0, the other set counting the documents
: satisfying that facet with number_of_items_generated greater than 0.  Seems

second:: interval faceting is just a fancy, more efficient, way of 
using "facet.query" if your queries are always over ranges.  there's 
nothing about interval faceting that is directly related to pivot 
faceting.

third: there isn't currently any generic support for faceting by a field, 
and then facet "those results" by some other field/criteria.  This is 
actively being worked on in issues like SOLR-6348 - but it doens't exist 
yet.

fourth: because you ultimately have a specific citeria for how 
you want to divide the facets, something similar to the behavior you are 
asking is available using "taged exclusions" on facets....

https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-LocalParametersforFaceting

...the basic idea you could follow is that you send additional fq params 
for each of the 2 criteria you want to lump things into 
(number_of_items_generated<0 and number_of_items_generated>0) but you tag 
those filters so they can individuall be "excluded" from facets -- then 
you use facet.field on your item_generator field twice (with different 
keys)  and in each case you exclude only one of those filters.

Here's a similar example to what you describe using the sample data that 
comes with solr...

http://localhost:8983/solr/select?rows=0&debug=query&q=inStock:true&fq={!tag=pricey}price:[100%20TO%20*]&fq={!tag=cheap}price:[*%20TO%20100}&facet=true&facet.field={!key=cheap_cats%20ex=pricey}cat&facet.field={!key=pricey_cats%20ex=cheap}cat

so "cheap_cats" gives you facet counts on the "cat" field but only for the 
"cheap" products (because it excludes the "pricey" fq) and "pricey_cats" 
gives you facet counts on the "cat" field for the "pricey" products by 
excluding the "cheap" fq.

note however that the numFound is 0 -- this works fine for getting the 
facet counts you wnat, but you'd need a second query q/ the filters to get 
the main result set since (i'm pretty sure) it's not possible to use "ex" 
on the main query to exclude filters from affecting the main result set.


-Hoss
http://www.lucidworks.com/