简体   繁体   中英

Method for converting a Document from the index into a SolrDocument suitable for inclusion in a SolrQueryResponse

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM