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 Robert Stewart <bs...@gmail.com> on 2011/11/15 21:12:49 UTC

naming facet queries?

Is there any way to give a name to a facet query, so you can pick
facet values from results using some name as a key (rather than
looking for match via the query itself)?

For example, in request handler I have:

<str name="facet.query">publish_date:[NOW-7DAY TO NOW]</str>
<str name="facet.query">publish_date:[NOW-1MONTH TO NOW]</str>

I'd like results to have names such as "last_week" and "last_month".
Otherwise client code needs to know to lookup values using the actual
query as the key, and that can be subject to change in solrconfig.xml.

I'd like to be able to something like this in solr config:

<str name="facet.query">{!name=last_week}publish_date:[NOW-7DAY TO NOW]</str>
<str name="facet.query">{!name=last_month}publish_date:[NOW-1MONTH TO NOW]</str>

And then get this in results:

<lst name="facet_counts">
 <lst name="facet_queries">
   <int name="last_week">10000</int>
   <int name="last_month">15000</int>
  </lst>


Thanks
Bob

Re: naming facet queries?

Posted by Erik Hatcher <er...@gmail.com>.
Yes... use key instead of name in your example below :)

	<http://wiki.apache.org/solr/SimpleFacetParameters#key_:_Changing_the_output_key>


On Nov 15, 2011, at 15:12 , Robert Stewart wrote:

> Is there any way to give a name to a facet query, so you can pick
> facet values from results using some name as a key (rather than
> looking for match via the query itself)?
> 
> For example, in request handler I have:
> 
> <str name="facet.query">publish_date:[NOW-7DAY TO NOW]</str>
> <str name="facet.query">publish_date:[NOW-1MONTH TO NOW]</str>
> 
> I'd like results to have names such as "last_week" and "last_month".
> Otherwise client code needs to know to lookup values using the actual
> query as the key, and that can be subject to change in solrconfig.xml.
> 
> I'd like to be able to something like this in solr config:
> 
> <str name="facet.query">{!name=last_week}publish_date:[NOW-7DAY TO NOW]</str>
> <str name="facet.query">{!name=last_month}publish_date:[NOW-1MONTH TO NOW]</str>
> 
> And then get this in results:
> 
> <lst name="facet_counts">
> <lst name="facet_queries">
>   <int name="last_week">10000</int>
>   <int name="last_month">15000</int>
>  </lst>
> 
> 
> Thanks
> Bob