每当我在Solr上执行查询时,即使是最简单的查询*:*,我也会收到错误消息
Exception in thread "main" org.apache.solr.client.solrj.SolrServerException: Error executing query
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:100)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
at com.atmire.dspace.versioning.ModificationLogger.search(ModificationLogger.java:294)
at com.atmire.dspace.versioning.ModificationsReporter.main(ModificationsReporter.java:92)
Caused by: org.apache.http.ParseException: Invalid content type:
at org.apache.http.entity.ContentType.parse(ContentType.java:233)
at org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:496)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:91)
... 3 more尽管在使用webclient或使用curl时,相同的查询运行得很好:
curl http://localhost:8080/solr/versioning/select\?q\=\*%3A\*\&wt\=json\&indent\=true
我很困惑为什么这个查询不能在java中工作。相关的java代码
SolrQuery query = new SolrQuery().setQuery("*:*");
query.setRows(rpp).setStart(start);
QueryResponse queryResponse = solr.query(query);
return queryResponse.getResults();看起来SolrQuery和solr都有显式设置Content-Type的选项,至少我在API文档中找不到。此外,我非常惊讶的是,如果我必须指定Content-Type,即使我不添加wt=json,它实际上也可以与curl一起工作。虽然我怀疑这是为了响应,而不是请求。
发布于 2016-09-01 09:04:37
看起来可能它实际上并没有指向Solr服务器。您是否可以仔细检查您之前的代码,看看您是否确实设置了正确的主机和端口(这不是您的默认设置),以及正确的集合。
https://stackoverflow.com/questions/39252934
复制相似问题