Problem with Facet Date Query

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Facet Date Query

AmitG
Hi,

I want to use date field with facet query.

This is my query:
q=productPublicationDate_product_dt:[*%20TO%20NOW]&facet=true&facet.field=productPublicationDate_product_dt:[*%20TO%20NOW]&qt=dismaxrequest

This is exception, I am facing after running this query.

- <lst name="facet_counts">
  <lst name="facet_queries" /> 
  <str name="exception">org.apache.solr.common.SolrException: undefined field productPublicationDate_product_dt:[* TO NOW] at org.apache.solr.schema.IndexSchema.getField(IndexSchema.java:994) at org.apache.solr.request.SimpleFacets.getTermCounts(SimpleFacets.java:152) at org.apache.solr.request.SimpleFacets.getFacetFieldCounts(SimpleFacets.java:182) at org.apache.solr.request.SimpleFacets.getFacetCounts(SimpleFacets.java:96) at org.apache.solr.handler.component.FacetComponent.process(FacetComponent.java:70) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:169) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1232) at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:303) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:232) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source)</str> 
</lst>

I have entered this field in solrConfig.xml also in the below manner.

    <lst name="invariants">
      <str name="facet.field">cat</str>
      <str name="facet.field">manu_exact</str>
      <str name="facet.query">price:[* TO 500]</str>
      <str name="facet.query">price:[500 TO *]</str>
          <str name="facet.query">productPublicationDate_product_dt:[* TO NOW/DAY-1MONTH]^2.2</str>
    </lst>


Do I need to do something else to run this query. I mean if I need to change something in config file or to change my query.

Please help.

thanks.
Amit Garg
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Facet Date Query

Erik Hatcher

On Mar 19, 2009, at 1:57 AM, dabboo wrote:

> This is my query:
> q=productPublicationDate_product_dt:[*%20TO
> %20NOW]&facet=true&facet.field=productPublicationDate_product_dt:[*
> %20TO%20NOW]&qt=dismaxrequest
>
> This is exception, I am facing after running this query.
>
> - <lst name="facet_counts">
>  <lst name="facet_queries" />
>  <str name="exception">org.apache.solr.common.SolrException: undefined
> field productPublicationDate_product_dt:[* TO NOW] at

Note the error message here....

>  <str name="facet.query">productPublicationDate_product_dt:[* TO
> NOW/DAY-1MONTH]^2.2</str>
>    </lst>
>
>
> Do I need to do something else to run this query.

Yes, you need to define that field in schema.xml

Also note that the boosting on that query isn't going to give you  
anything useful - all you get back from that facet.query is a single  
count of matching documents.

        Erik

Reply | Threaded
Open this post in threaded view
|

Re: Problem with Facet Date Query

AmitG
Thanks Eric. But where in schema.xml, I will have to give this value and how.
Erik Hatcher wrote
On Mar 19, 2009, at 1:57 AM, dabboo wrote:
> This is my query:
> q=productPublicationDate_product_dt:[*%20TO
> %20NOW]&facet=true&facet.field=productPublicationDate_product_dt:[*
> %20TO%20NOW]&qt=dismaxrequest
>
> This is exception, I am facing after running this query.
>
> - <lst name="facet_counts">
>  <lst name="facet_queries" />
>  <str name="exception">org.apache.solr.common.SolrException: undefined
> field productPublicationDate_product_dt:[* TO NOW] at

Note the error message here....

>  <str name="facet.query">productPublicationDate_product_dt:[* TO
> NOW/DAY-1MONTH]^2.2</str>
>    </lst>
>
>
> Do I need to do something else to run this query.

Yes, you need to define that field in schema.xml

Also note that the boosting on that query isn't going to give you  
anything useful - all you get back from that facet.query is a single  
count of matching documents.

        Erik
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Facet Date Query

hossman
In reply to this post by AmitG
:
: This is my query:
: q=productPublicationDate_product_dt:[*%20TO%20NOW]&facet=true&facet.field=productPublicationDate_product_dt:[*%20TO%20NOW]&qt=dismaxrequest

that specific error is happening because you are passing this string...

        productPublicationDate_product_dt:[*%20TO%20NOW]

...to the facet.field param.  that parameter expects the name of a field,
and it will then facet on all the indexed values.  what you are passing it
isn't the name of a field, you are passing it a query string.  if you want
the faceting count for a query string, use the facet.query param, which
you already seem to be doing with a different range of dates by hardcoding
it into your solrconfig...

: I have entered this field in solrConfig.xml also in the below manner.
:
:     <lst name="invariants">
:       <str name="facet.field">cat</str>
:       <str name="facet.field">manu_exact</str>
:       <str name="facet.query">price:[* TO 500]</str>
:       <str name="facet.query">price:[500 TO *]</str>
:  <str name="facet.query">productPublicationDate_product_dt:[* TO
: NOW/DAY-1MONTH]^2.2</str>
:     </lst>

I'm not entirely sure what it is you are trying to do, but you're also
going to have problems because you are using the "standard" query syntax
in your q param, but you have specified qt=dismax.

Please explain what your *goal* is and then people can help you explain
how to achieve your goal ... what you've got here in your example makes no
sense, and it's not clear what advice to give you to get it to make
sense without knowing what it is you want to do.  This is similar to an XY
Problem...

http://people.apache.org/~hossman/#xyproblem
XY Problem

Your question appears to be an "XY Problem" ... that is: you are dealing
with "X", you are assuming "Y" will help you, and you are asking about "Y"
without giving more details about the "X" so that we can understand the
full issue.  Perhaps the best solution doesn't involve "Y" at all?
See Also: http://www.perlmonks.org/index.pl?node_id=542341




-Hoss