如何在Solr中将ResponseWriter设置为非默认值 [英] How to set ResponseWriter to non-default in Solr
问题描述
我有以下代码,它们只是在搜索Solr Server.
SolrServer server = new CommonsHttpSolrServer(url);
SolrQuery searchquery = new SolrQuery("company profile");
QueryResponse response = server.query(searchquery)
我希望在json中有响应,而不是默认值xml.因此,我进入了solrconfig.xml文件并启用了以下行:
<queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter" />
但是,从控制台,我仍然将wt = javabin编码为搜索查询请求.
此外,我已经修改了上面的代码,如下所示:
SolrServer server = new CommonsHttpSolrServer(url);
SolrQuery searchquery = new SolrQuery("company profile");
searchquery.setParam("wt", "json");
QueryResponse response = server.query(searchquery)
但是我仍然要进行wt=javabin
编码和wt=json
附加,这样查询现在看起来像这样:
webapp/solr path=/select params={wt=javabin&wt=json}
我在做错什么吗?
谢谢
SolrJ仅支持 I want to have the response in json, other than the default which is xml. So I went into the solrconfig.xml file and enabled the following line: However, from the console, I'm still getting wt=javabin encoded to the search query request. Also, I've modified the above code like this: But I'm still getting Is there anything I'm doing wrong? Thanks SolrJ only supports the But why would you want to use JSON? Javabin is by far the format which provides the best decompression speed, its drawback being that is is not human-readable, on the contrary to JSON and XML (which is not a problem in this case since SolrJ is parsing the result for you). 这篇关于如何在Solr中将ResponseWriter设置为非默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!javabin
和xml
格式(可通过<queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter" />
SolrServer server = new CommonsHttpSolrServer(url);
SolrQuery searchquery = new SolrQuery("company profile");
searchquery.setParam("wt", "json");
QueryResponse response = server.query(searchquery)
wt=javabin
encoded and wt=json
also appended, such that the query now looks like this:webapp/solr path=/select params={wt=javabin&wt=json}
javabin
and xml
formats (configurable with CommonHttpSolrServer.setParser).