How can use the /export request handler via SolrJ?

蹲街弑〆低调 提交于 2019-12-06 14:57:34

问题


I'm using Solr 4.10.

I have enabled the /export request handler for an index by adding this to the solrconfig.xml (as mentioned here: https://cwiki.apache.org/confluence/display/solr/Exporting+Result+Sets):

<requestHandler name="/export" class="solr.SearchHandler">
  <lst name="invariants">
    <str name="rq">{!xport}</str>
    <str name="wt">xsort</str>
    <str name="distrib">false</str>
  </lst>
  <arr name="components">
    <str>query</str>
  </arr>
</requestHandler>

Now I can use: http://localhost:8983/solr/index/select?.... as well as http://localhost:8983/solr/index/export?.... from a browser or curl.

But, I cannot get it to run properly using SolrJ.

I tried (as suggested here: https://lucene.apache.org/solr/4_10_0/solr-solrj/index.html):

SolrQuery query = new SolrQuery();
...
query.setRequestHandler("/export");
...
httpSolrServer.query(query);

The query now has a parameter &qt=export. It blew up giving me:

org.apache.solr.client.solrj.SolrServerException: Error executing query

More search suggested using SolrRequest instead of SolrQuery, I tried it:

SolrQuery query = new SolrQuery();
...
query.setRequestHandler("/export");
SolrRequest solrRequest = new QueryRequest(query);
httpSolrServer.request(solrRequest);

Now I get:

java.nio.charset.UnsupportedCharsetException: gzip

Any ideas?


---edit---

I found an option in httpSolrServer.request() to add a ResponseParser. I found 4 ResponseParsers. Tried them all, the only one that worked was NoOpResponseParser. Now I have the correct results, but dumped as a plain string in a single entry in a NamedList. I tried to parse it as JSON, but it's not in proper format. Each 30,000 document, there's a missing , !!!!.

I returned back to solrconfig.xml and changed wt in the /export handler from xsort to json. Now the response format has changed, but it's also not in proper format (data is incomplete) !!!!. And XML is not supported.

I'm truly baffled.

来源:https://stackoverflow.com/questions/33540577/how-can-use-the-export-request-handler-via-solrj

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!