-1

Struggling to find method for converting a Document from the index into a SolrDocument suitable for inclusion in a SolrQueryResponse for solr-core-5.5.2.jar

solr-core-5.2.1.jar had an ResponseWriterUtil.toSolrDocument(Document doc, IndexSchema schema) which is removed from solr-core-5.3.0 version

Thanks in advance

  • please [edit] your question to clarify your specific problem or add additional details to highlight exactly what you need. – hongsy Jan 24 '20 at 07:33

1 Answers1

0

The ResponseWriterUtil class has been replaced with DocsStreamer (org.apache.solr.response.DocsStreamer).

Depending on the API version, you either give it it's parameters from the ResultContext (for 5.5.2):

DocsStreamer(DocList docList, Query query, SolrQueryRequest req, ReturnFields returnFields)
static SolrDocument getDoc(Document doc, IndexSchema schema) 

or in newer versions, you give it the resultcontext directly:

DocsStreamer(ResultContext rctx) 
static SolrDocument getDoc(Document doc, IndexSchema schema) 

If you use the constructor you get an iterator over the doclist from the result context, and you can use .next() to move to the next document as necessary.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84