问题
I have a solr schema like this
<fields>
<field name="id" type="string" indexed="false" stored="true" required="true" />
<field name="product" type="string" indexed="true" stored="true" required="true" />
<field name="vendor" type="string" indexed="true" stored="true" required="true" />
<field name="language" type="string" indexed="true" stored="true" required="true" />
<field name="TotalInvoices" type="float" indexed="true" stored="true" required="true"/>
</fields>
I am querying the schema and the result is like this
product,Vendor,Invoice
abc,vendor1,49206.75999999998
abc,vendor2,35654.98000000001
abc,vendor2,94861.25999999998
abc,vendor3,990.9600000000012
abc,vendor3,990.9600000000012
abc,vendor3,990.960000000001
I want to group the result by the vendor field so I post a query like this
http://localhost:8983/solr/gettingstarted_shard2_replica2/select?q=abc
&fl=product%2Cvendor%2CTotalInvoices
&wt=json
&indent=true
&debugQuery=true
&group=true
&group.field=vendor
I am getting an error for this in the debug field.
"error":{ "msg":"org.apache.solr.client.solrj.SolrServerException: No live SolrServers available to handle this request:[http://10.192.17.110:7574/solr/gettingstarted_shard2_replica1, http://10.192.17.110:8983/solr/gettingstarted_shard1_replica2, http://10.192.17.110:7574/solr/gettingstarted_shard1_replica1, http://10.192.17.110:8983/solr/gettingstarted_shard2_replica2]", "trace":"org.apache.solr.common.SolrException: org.apache.solr.client.solrj.SolrServerException: No live SolrServers available to handle this request:[http://10.192.17.110:7574/solr/gettingstarted_shard2_replica1, http://10.192.17.110:8983/solr/gettingstarted_shard1_replica2, http://10.192.17.110:7574/solr/gettingstarted_shard1_replica1, http://10.192.17.110:8983/solr/gettingstarted_shard2_replica2]\n\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:342)\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:1984)\n\tat org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:829)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:446)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:220)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)\n\tat org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:247)\n\tat org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:210)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:368)\n\tat org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)\n\tat org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)\n\tat org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)\n\tat org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)\n\tat org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)\n\tat org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)\n\tat org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)\n\tat org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\n\tat java.lang.Thread.run(Thread.java:745)\nCaused by: org.apache.solr.client.solrj.SolrServerException: No live SolrServers available to handle this request:[http://10.192.17.110:7574/solr/gettingstarted_shard2_replica1, http://10.192.17.110:8983/solr/gettingstarted_shard1_replica2, http://10.192.17.110:7574/solr/gettingstarted_shard1_replica1, http://10.192.17.110:8983/solr/gettingstarted_shard2_replica2]\n\tat org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(LBHttpSolrClient.java:349)\n\tat org.apache.solr.handler.component.HttpShardHandlerFactory.makeLoadBalancedRequest(HttpShardHandlerFactory.java:226)\n\tat org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:224)\n\tat org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:184)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:262)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\n\t... 1 more\nCaused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://10.192.17.110:8983/solr/gettingstarted_shard1_replica2: unexpected docvalues type SORTED_SET for field 'vendor' (expected=SORTED). Use UninvertingReader or index with docvalues.\n\tat org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:556)\n\tat org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:233)\n\tat org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:225)\n\tat org.apache.solr.client.solrj.impl.LBHttpSolrClient.doRequest(LBHttpSolrClient.java:370)\n\tat org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(LBHttpSolrClient.java:338)\n\t... 9 more\n", "code":500}}
Please help me out.
回答1:
I hit the same problem when trying to sort on field 'ViewCount':
unexpected docvalues type SORTED_SET for field 'ViewCount' (expected=SORTED) ...
Error understanding: From here
Any Trie* numeric fields, date fields and EnumField.`enter code here`
If the field is single-valued (i.e., multi-valued is false), Lucene will use the NUMERIC type.
If the field is multi-valued, Lucene will use the SORTED_SET type.
Looks like the error is caused by the "multi-valued" property of the field "ViewCount". Further more, as the doc, the field's "indexed" property has to be true.
I have a core name "bigdata".
My solution:
delete all documents in "bigdata"
curl http://localhost:8983/solr/bigdata/update --data ':' -H 'Content-type:text/xml; charset=utf-8' curl http://localhost:8983/solr/bigdata/update --data '' -H 'Content-type:text/xml; charset=utf-8'
change the field to long(or any type that's not multi-valued) and indexed
curl -X POST -H 'Content-type:application/json' --data-binary '{ "replace-field":{ "name":"ViewCount", "type":"long", "multiValued":false, "indexed":true, "stored":true } }' http://localhost:8983/solr/bigdata/schema
reload "bigdata"
http://localhost:8983/solr/admin/cores?action=RELOAD&core=bigdata
import your data to "bigdata" again
reload "bigdata"
http://localhost:8983/solr/admin/cores?action=RELOAD&core=bigdata
Issue1: delete all docs maybe painful to someone. I tried the steps above without delete and re-import all docs, but not worked. Looks like that's what Crypt experienced.
Issue2: if you use seamless mode. I mean you don't manually edit the schema, you need to set the schema immutable in "solrconfig.xml" before re-import your data. The relevant doc is here
来源:https://stackoverflow.com/questions/30347597/solr-result-grouping-error-unexpected-docvalues-type-sorted-set-for-field-vend