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 samabhiK <qe...@gmail.com> on 2013/05/22 13:42:35 UTC

Solr Faceting doesn't return values.

Hello,

I have a field defined in my schema.xml like so:

<field name="sa_site_city" type="string" indexed="true" stored="true"/>

string is a type :

<fieldType name="string" class="solr.StrField" sortMissingLast="true" />

When I run the query for faceting data by the city:

http://XX.XX.XX.XX/solr/collection1/select?q=mm_state_code&wt=json&indent=true&facet=true&facet.field=sa_site_city

 I get empty result like so:

{
  "responseHeader":{
    "status":0,
    "QTime":1,
    "params":{
      "facet":"true",
      "indent":"true",
      "q":"mm_state_code",
      "facet.field":"sa_site_city",
      "wt":"json"}},
  "response":{"numFound":0,"start":0,"docs":[]
  },
  "facet_counts":{
    "facet_queries":{},
    "facet_fields":{
      "sa_site_city":[]},
    "facet_dates":{},
    "facet_ranges":{}}}

I wonder what am I doing wrong?





--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Faceting doesn't return values.

Posted by Sandeep Mestry <sa...@gmail.com>.
*<str name="msg">org.apache.solr.search.SyntaxError: Cannot parse
'*mm_state_code:(**TX)*': Encountered " ":" ": "" at line 1, column 14.
Was expecting one of:*

This suggests to me that you kept the df parameter in the query hence it
was forming mm_state_code:mm_state_code:(TX), can you try exactly they way
I gave you - i.e. without the df parameter?
Also, can you post schema.xml and /select handler config from
solrconfig.xml?


On 22 May 2013 18:36, samabhiK <qe...@gmail.com> wrote:

> When I use your query, I get :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <response>
>
> <lst name="responseHeader">
>   <int name="status">400</int>
>   <int name="QTime">12</int>
>   <lst name="params">
>     <str name="facet">true</str>
>     <str name="df">mm_state_code</str>
>     <str name="indent">true</str>
>     <str name="q">*mm_state_code:(**TX)*</str>
>     <str name="_">1369244078714</str>
>     <str name="debug">all</str>
>     <str name="facet.field">sa_site_city</str>
>     <str name="wt">xml</str>
>   </lst>
> </lst>
> <lst name="error">
>   <str name="msg">org.apache.solr.search.SyntaxError: Cannot parse
> '*mm_state_code:(**TX)*': Encountered " ":" ": "" at line 1, column 14.
> Was expecting one of:
>     <EOF>
>     <AND> ...
>     <OR> ...
>     <NOT> ...
>     "+" ...
>     "-" ...
>     <BAREOPER> ...
>     "(" ...
>     "*" ...
>     "^" ...
>     <QUOTED> ...
>     <TERM> ...
>     <FUZZY_SLOP> ...
>     <PREFIXTERM> ...
>     <WILDTERM> ...
>     <REGEXPTERM> ...
>     "[" ...
>     "{" ...
>     <LPARAMS> ...
>     <NUMBER> ...
>     </str>
>   <int name="code">400</int>
> </lst>
> </response>
>
> Not sure why the data wont show up. Almost all the records has the field
> sa_site_city has data and is also indexed. :(
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276p4065406.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Solr Faceting doesn't return values.

Posted by samabhiK <qe...@gmail.com>.
When I use your query, I get :

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">400</int>
  <int name="QTime">12</int>
  <lst name="params">
    <str name="facet">true</str>
    <str name="df">mm_state_code</str>
    <str name="indent">true</str>
    <str name="q">*mm_state_code:(**TX)*</str>
    <str name="_">1369244078714</str>
    <str name="debug">all</str>
    <str name="facet.field">sa_site_city</str>
    <str name="wt">xml</str>
  </lst>
</lst>
<lst name="error">
  <str name="msg">org.apache.solr.search.SyntaxError: Cannot parse
'*mm_state_code:(**TX)*': Encountered " ":" ": "" at line 1, column 14.
Was expecting one of:
    <EOF> 
    <AND> ...
    <OR> ...
    <NOT> ...
    "+" ...
    "-" ...
    <BAREOPER> ...
    "(" ...
    "*" ...
    "^" ...
    <QUOTED> ...
    <TERM> ...
    <FUZZY_SLOP> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    <REGEXPTERM> ...
    "[" ...
    "{" ...
    <LPARAMS> ...
    <NUMBER> ...
    </str>
  <int name="code">400</int>
</lst>
</response>

Not sure why the data wont show up. Almost all the records has the field
sa_site_city has data and is also indexed. :(  



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276p4065406.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Faceting doesn't return values.

Posted by Sandeep Mestry <sa...@gmail.com>.
>From the response you've mentioned it appears to me that the query term TX
is searched against sa_site_city instead of mm_state_code.
Can you try your query like below:

http://xx.xx.xx.xx/solr/collection1/select?q=*mm_state_code:(**TX)*
&wt=xml&indent=true&facet=true&facet.field=sa_site_city&debug=all

and post your output?

On 22 May 2013 17:13, samabhiK <qe...@gmail.com> wrote:

> <str name="df">sa_site_city</str>

Re: Solr Faceting doesn't return values.

Posted by samabhiK <qe...@gmail.com>.
Thanks for your reply.

I have my request url modified like this:
http://xx.xx.xx.xx/solr/collection1/select?q=TX&df=mm_state_code&wt=xml&indent=true&facet=true&facet.field=sa_site_city&debug=all

Facet Filed = sa_site_city ( city wise facet)
Default Filed = mm_state_code
Query= TX

When I run this query, I get something like this:

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">3</int>
  <lst name="params">
    <str name="facet">true</str>
    <str name="df">sa_site_city</str>
    <str name="indent">true</str>
    <str name="q">TX</str>
    <str name="_">1369238921109</str>
    <str name="debug">all</str>
    <str name="facet.field">sa_site_city</str>
    <str name="wt">xml</str>
  </lst>
</lst>
<result name="response" numFound="0" start="0">
</result>
<lst name="facet_counts">
  <lst name="facet_queries"/>
  <lst name="facet_fields">
    <lst name="sa_site_city"/>
  </lst>
  <lst name="facet_dates"/>
  <lst name="facet_ranges"/>
</lst>
<lst name="debug">
  <str name="rawquerystring">TX</str>
  <str name="querystring">TX</str>
  <str name="parsedquery">sa_site_city:TX</str>
  <str name="parsedquery_toString">sa_site_city:TX</str>
  <lst name="explain"/>
  <str name="QParser">LuceneQParser</str>
  <lst name="timing">
    <double name="time">2.0</double>
    <lst name="prepare">
      <double name="time">0.0</double>
      <lst name="query">
        <double name="time">0.0</double>
      </lst>
      <lst name="facet">
        <double name="time">0.0</double>
      </lst>
      <lst name="mlt">
        <double name="time">0.0</double>
      </lst>
      <lst name="highlight">
        <double name="time">0.0</double>
      </lst>
      <lst name="stats">
        <double name="time">0.0</double>
      </lst>
      <lst name="debug">
        <double name="time">0.0</double>
      </lst>
    </lst>
    <lst name="process">
      <double name="time">2.0</double>
      <lst name="query">
        <double name="time">1.0</double>
      </lst>
      <lst name="facet">
        <double name="time">1.0</double>
      </lst>
      <lst name="mlt">
        <double name="time">0.0</double>
      </lst>
      <lst name="highlight">
        <double name="time">0.0</double>
      </lst>
      <lst name="stats">
        <double name="time">0.0</double>
      </lst>
      <lst name="debug">
        <double name="time">0.0</double>
      </lst>
    </lst>
  </lst>
</lst>
</response>

I do have the data in my index and that I verified by running other queries.
I can't figure out what I am missing.








--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276p4065360.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Faceting doesn't return values.

Posted by Sandeep Mestry <sa...@gmail.com>.
Hi There,

Not sure I understand your problem correctly, but is 'mm_state_code' a real
value or is it field name?
Also, as Erick pointed out above, the facets are not calculated if there
are no results. Hence you get no facets.

You have mentioned which facets you want but you haven't mentioned which
field you want to search against. That field should be defined in df
parameter instead of sa_property_id.

Can you post example solr document you're indexing?

-Sandeep


On 22 May 2013 14:28, samabhiK <qe...@gmail.com> wrote:

> Ok my bad.
>
> I do have a default field defined in the /select handler in the config
> file.
>
> <lst name="defaults">
>        <str name="echoParams">explicit</str>
>        <int name="rows">10</int>
>        <str name="df">sa_property_id</str>
> </lst>
>
> But then how do I change my query now?
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276p4065298.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Solr Faceting doesn't return values.

Posted by samabhiK <qe...@gmail.com>.
Ok my bad.

I do have a default field defined in the /select handler in the config file.

<lst name="defaults">
       <str name="echoParams">explicit</str>
       <int name="rows">10</int>
       <str name="df">sa_property_id</str>
</lst>

But then how do I change my query now?




--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276p4065298.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Faceting doesn't return values.

Posted by samabhiK <qe...@gmail.com>.
Ok after I added debug=all to the query, I get:

{
  "responseHeader":{
    "status":0,
    "QTime":11,
    "params":{
      "facet":"true",
      "indent":"true",
      "q":"mm_state_code",
      "debug":"all",
      "facet.field":"sa_site_city",
      "wt":"json"}},
  "response":{"numFound":0,"start":0,"docs":[]
  },
  "facet_counts":{
    "facet_queries":{},
    "facet_fields":{
      "sa_site_city":[]},
    "facet_dates":{},
    "facet_ranges":{}},
  "debug":{
    "rawquerystring":"mm_state_code",
    "querystring":"mm_state_code",
    "parsedquery":"sa_property_id:mm_state_code",
    "parsedquery_toString":"sa_property_id:mm_state_code",
    "explain":{},
    "QParser":"LuceneQParser",
    "timing":{
      "time":4.0,
      "prepare":{
        "time":2.0,
        "query":{
          "time":0.0},
        "facet":{
          "time":0.0},
        "mlt":{
          "time":0.0},
        "highlight":{
          "time":0.0},
        "stats":{
          "time":0.0},
        "debug":{
          "time":0.0}},
      "process":{
        "time":1.0,
        "query":{
          "time":0.0},
        "facet":{
          "time":0.0},
        "mlt":{
          "time":0.0},
        "highlight":{
          "time":0.0},
        "stats":{
          "time":0.0},
        "debug":{
          "time":1.0}}}}}

I have not defined any default facet filed, in the handler in solrconfig.xml
file.
Also, there is plenty of data available and the field sa_site_city

What I am trying to understand is this:

"parsedquery":"sa_property_id:mm_state_code"

I have a field sa_property_id in the schema but i have not defined it in the
query nor in solrconfig.xml, but why is it still evaluated? Any help in
solving this problem will be greatly appreciated.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276p4065294.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Faceting doesn't return values.

Posted by Erick Erickson <er...@gmail.com>.
Probably you're not querying the field you think you are. Try adding
&debug=all to the URL and I think you'll see something like

default_search_field:mm_state_code

Which means you're searching for the literal phrase "mm_state_code" in
your default search field (defined in solrconfig.xml for the handler
you're using).

You won't get any facets if you don't have any documents that match.

Best
Erick

On Wed, May 22, 2013 at 7:42 AM, samabhiK <qe...@gmail.com> wrote:
> Hello,
>
> I have a field defined in my schema.xml like so:
>
> <field name="sa_site_city" type="string" indexed="true" stored="true"/>
>
> string is a type :
>
> <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
>
> When I run the query for faceting data by the city:
>
> http://XX.XX.XX.XX/solr/collection1/select?q=mm_state_code&wt=json&indent=true&facet=true&facet.field=sa_site_city
>
>  I get empty result like so:
>
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":1,
>     "params":{
>       "facet":"true",
>       "indent":"true",
>       "q":"mm_state_code",
>       "facet.field":"sa_site_city",
>       "wt":"json"}},
>   "response":{"numFound":0,"start":0,"docs":[]
>   },
>   "facet_counts":{
>     "facet_queries":{},
>     "facet_fields":{
>       "sa_site_city":[]},
>     "facet_dates":{},
>     "facet_ranges":{}}}
>
> I wonder what am I doing wrong?
>
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-Faceting-doesn-t-return-values-tp4065276.html
> Sent from the Solr - User mailing list archive at Nabble.com.