views:

89

answers:

1

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.

+2  A: 

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...
Pascal Dimassimo
+1 beat me to it :)
Mauricio Scheffer
Managed to hack it in using copyFields instead, and no time to change at this point, but this seems like a reasonable solution as well. Have some reputation! :)
Daniel
Much appreciated! :)
Pascal Dimassimo