Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr sorting issue

I am getting this weird error message can not sort on multivalued field: fieldname on all the indexed fields. This is the full error message from solr

</head><body><h1>HTTP Status 400 - can not sort on multivalued field: price</h1><hr/><p><b>type</b> Status report</p><p><b>message</b>can not sort on multivalued field: price</p><p><b>description</b>The request sent by the client was syntactically incorrect (can not sort on multivalued field: price).</p><hr/><h3>GlassFish Server Open Source Edition 3.1</h3></body></html>

I am sure that my indexed field doesnt have multiValued=true set on

 <field name="price" type="float" indexed="true" stored="true" multivalued="false" />

to make sure that i have added multiValued=false, but i am still getting the same error.

This is the URL request sent to solr

http://localhost:8080/apache-solr-3.1.0/select?wt=ruby&q=flat&fl=_id&sort=price+asc&limit=5&offset=0

and relevant rsolr call

res = solr.get 'select', :params => {
              :q =>'flat',
              :fl => "_id",
              :sort=>'price asc',
              'limit' => 5,
              'offset' => 0
          }

It all works fine if i remove the sort from the request.

Can some one help me out..

PS: I do have only one multivalued field in the document, but thats not used in the sort

Update:

Here the complete stack-trace from solr log

[#|2011-12-06T16:03:35.813+0530|SEVERE|glassfish3.1|org.apache.solr.core.SolrCore|_ThreadID=22;_ThreadName=Thread-1;|org.apache.solr.common.SolrException: can not sort on multivalued field: price
    at org.apache.solr.schema.SchemaField.checkSortability(SchemaField.java:161)
    at org.apache.solr.schema.TrieField.getSortField(TrieField.java:128)
    at org.apache.solr.schema.SchemaField.getSortField(SchemaField.java:144)
    at org.apache.solr.search.QueryParsing.parseSort(QueryParsing.java:385)
    at org.apache.solr.search.QParser.getSort(QParser.java:251)
    at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:102)
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:173)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
|#]

[#|2011-12-06T16:03:35.814+0530|INFO|glassfish3.1|org.apache.solr.core.SolrCore|_ThreadID=22;_ThreadName=Thread-1;|[] webapp=/apache-solr-3.5.0 path=/select params={wt=ruby&q=flat&fl=_id&sort=price+asc&limit=5&offset=0} status=400 QTime=42 |#]

Update2:

As suggested by @Mateg i got the field details from the schema page. see below

Field: price
Field Type: FLOAT

Properties: Indexed, Tokenized, Stored, Multivalued, Omit Norms

Schema: Indexed, Tokenized, Stored, Multivalued, Omit Norms

Index: Indexed, Tokenized, Stored, Omit Norms

Index Analyzer: org.apache.solr.analysis.TokenizerChain DETAILS

Query Analyzer: org.apache.solr.analysis.TokenizerChain DETAILS

It says the price field is tokenized and multivalued. Its interesting not only this field is like that, all other field are also multivalued.

like image 658
RameshVel Avatar asked Dec 06 '11 09:12

RameshVel


People also ask

What is boost in SOLR?

The “boost” parameter is very similar to the “bf” parameter, but instead of adding its result to the final score, it will multiply it. This is only available in the “Extended Dismax Query Parser” or the “Lucid Query Parser”.

What are dynamic fields in Solr?

Dynamic fields allow Solr to index fields that you did not explicitly define in your schema. This is useful if you discover you have forgotten to define one or more fields. Dynamic fields can make your application less brittle by providing some flexibility in the documents you can add to Solr.

What is DF in SOLR?

The df stands for default field , while the qf stands for query fields . The field defined by the df parameter is used when no fields are mentioned in the query. For example if you are running a query like q=solr and you have df=title the query itself will actually be title:solr .


1 Answers

What a day , I finally found the problem after long struggle. Thanks to everyone

  • First of all i am not aware of setting the version number in schema file. As per the documentation default value for multi value is false from the version 1.1
   1.0: multiValued attribute did not exist, all fields are multiValued by nature
   1.1: multiValued attribute introduced, false by default

But i was using the old schema file with the version 1.0. So all fields are set to multiValued by default.

Every time i upgraded the solr, i just copy pasted the old schema file.

Now it works fine after changing this to the current version 1.4.

  <schema name="ItemSearch" version="1.4">
like image 85
RameshVel Avatar answered Oct 18 '22 06:10

RameshVel