[
https://issues.apache.org/jira/browse/SOLR-5478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13867876#comment-13867876
]
Robert Muir commented on SOLR-5478:
-----------------------------------
This is how i do it. I can give you a patch with my code if you want as well.
But its not perfect:
* ideally this logic really would not be in a response writer at all, thats
messy.
* currently only works for string fields. really if the id is numeric, we
should use the NumericDocValues, etc.
* in fact the whole thing is a hack: really solr should use the internal lucene
docid for distributed search.
{code}
Set<String> fnames = returnFields.getLuceneFieldNames();
context.iterator = ids.iterator();
final boolean onlyID = fnames != null && (fnames.equals(idOnly) ||
fnames.equals(idAndScore));
if (onlyID) {
// optimized case: only the ids are needed.
List<AtomicReaderContext> leaves =
searcher.getIndexReader().leaves();
BytesRef ref = new BytesRef();
for (int i = 0; i < sz; i++) {
int id = context.iterator.nextDoc();
int subIndex = ReaderUtil.subIndex(id, leaves);
AtomicReaderContext ctx = leaves.get(subIndex);
ctx.reader().getSortedDocValues(uniqueKeyField).get(id -
ctx.docBase, ref);
Document doc = new Document();
doc.add(new StringField(uniqueKeyField, ref.utf8ToString(),
Field.Store.YES));
SolrDocument sdoc = getDoc(doc);
if (transformer != null) {
transformer.transform(sdoc, id);
}
codec.writeSolrDocument(sdoc);
}
} else {
{code}
> Speed-up distributed search with high rows param or deep paging by
> transforming docId's to uniqueKey via memory docValues
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: SOLR-5478
> URL: https://issues.apache.org/jira/browse/SOLR-5478
> Project: Solr
> Issue Type: Improvement
> Components: Response Writers
> Affects Versions: 4.5
> Reporter: Manuel Lenormand
> Fix For: 4.7
>
> Attachments: SOLR-5478.patch, SOLR-5478.patch
>
>
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]