dre*_*ute 2 java lucene solr solrj
我有以下代码,它只是搜索 Solr 服务器。
SolrServer server = new CommonsHttpSolrServer(url);
SolrQuery searchquery = new SolrQuery("company profile");
QueryResponse response = server.query(searchquery)
Run Code Online (Sandbox Code Playgroud)
我想在 json 中有响应,而不是默认的 xml。所以我进入了 solrconfig.xml 文件并启用了以下行:
<queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter" />
Run Code Online (Sandbox Code Playgroud)
但是,在控制台中,我仍然将 wt=javabin 编码到搜索查询请求中。
另外,我已经像这样修改了上面的代码:
SolrServer server = new CommonsHttpSolrServer(url);
SolrQuery searchquery = new SolrQuery("company profile");
searchquery.setParam("wt", "json");
QueryResponse response = server.query(searchquery)
Run Code Online (Sandbox Code Playgroud)
但我仍在wt=javabin
编码和wt=json
附加,这样查询现在看起来像这样:
webapp/solr path=/select params={wt=javabin&wt=json}
Run Code Online (Sandbox Code Playgroud)
有什么我做错了吗?
谢谢
SolrJ 仅支持javabin
和xml
格式(可通过CommonHttpSolrServer.setParser 进行配置)。
但是为什么要使用 JSON?Javabin 是迄今为止提供最佳解压速度的格式,它的缺点是不是人类可读的,与 JSON 和 XML 相反(在这种情况下这不是问题,因为 SolrJ 正在为您解析结果)。
归档时间: |
|
查看次数: |
4696 次 |
最近记录: |