Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr multiple facet dates

According to the Apache Solr documentation on facets, I can use keys because: 'This can be helpful when faceting on the same field multiple times with different exclusions.'

I need them because I want to have a facet that gives me 'Last day', 'Last week', 'Last month' options.

However, when I specify a query with the following options set:

http://URL/select?
...unrelated...
facet=true&
facet.date={!key=some_key}created&
f.some_key.facet.date.start=NOW/DAY-1DAY&
f.some_key.facet.date.end=NOW/DAY&
f.some_key.facet.date.gap=NOW/DAY+1DAY
...unrelated...

Solr complains about:

[exception] => org.apache.solr.common.SolrException: Missing required parameter: f.created.facet.date.start (or default: facet.date.start)

When I set facet.date.start, or f.created.facet.date.start, they will override the fields of my some_key (start/end/gap) and this is useless because I need multiple keys... Can anyone point me in the right direction here? Due to limitations of the library I am using, this needs to be done in a single query.

like image 956
Daniel Sloof Avatar asked Jun 18 '10 10:06

Daniel Sloof


1 Answers

You could use facet queries:

http://URL/select?
...unrelated...
facet=true&    
facet.query=[NOW-1DAY TO NOW]&
facet.query=[NOW-7DAY TO NOW]&
facet.query=[NOW-1MONTH TO NOW]&
...unrelated...
like image 171
Pascal Dimassimo Avatar answered Sep 24 '22 02:09

Pascal Dimassimo