首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SolrJ内容类型无效

SolrJ内容类型无效
EN

Stack Overflow用户
提问于 2016-08-31 22:54:31
回答 1查看 2K关注 0票数 0

每当我在Solr上执行查询时,即使是最简单的查询*:*,我也会收到错误消息

代码语言:javascript
复制
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代码

代码语言:javascript
复制
    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一起工作。虽然我怀疑这是为了响应,而不是请求。

EN

回答 1

Stack Overflow用户

发布于 2016-09-01 09:04:37

看起来可能它实际上并没有指向Solr服务器。您是否可以仔细检查您之前的代码,看看您是否确实设置了正确的主机和端口(这不是您的默认设置),以及正确的集合。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39252934

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档