mirror of https://github.com/apache/lucene.git
SOLR-651: fix - get the searcher and schema from the request instead of the core
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@708621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1dfb5f4d58
commit
9c3ab6d75f
|
@ -107,30 +107,26 @@ public class TermVectorComponent extends SearchComponent implements SolrCoreAwar
|
||||||
DocList list = listAndSet.docList;
|
DocList list = listAndSet.docList;
|
||||||
iter = list.iterator();
|
iter = list.iterator();
|
||||||
}
|
}
|
||||||
SolrCore core = rb.req.getCore();
|
SolrIndexSearcher searcher = rb.req.getSearcher();
|
||||||
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
|
|
||||||
try {
|
IndexReader reader = searcher.getReader();
|
||||||
IndexReader reader = searcher.get().getReader();
|
//the TVMapper is a TermVectorMapper which can be used to optimize loading of Term Vectors
|
||||||
//the TVMapper is a TermVectorMapper which can be used to optimize loading of Term Vectors
|
TVMapper mapper = new TVMapper(fields, reader, termFreq, positions, offsets, idf, tfIdf);
|
||||||
TVMapper mapper = new TVMapper(fields, reader, termFreq, positions, offsets, idf, tfIdf);
|
IndexSchema schema = rb.req.getSchema();
|
||||||
IndexSchema schema = core.getSchema();
|
String uniqFieldName = schema.getUniqueKeyField().getName();
|
||||||
String uniqFieldName = schema.getUniqueKeyField().getName();
|
//Only load the id field
|
||||||
//Only load the id field
|
SetBasedFieldSelector fieldSelector = new SetBasedFieldSelector(Collections.singleton(uniqFieldName), Collections.emptySet());
|
||||||
SetBasedFieldSelector fieldSelector = new SetBasedFieldSelector(Collections.singleton(uniqFieldName), Collections.emptySet());
|
while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
Integer docId = iter.next();
|
||||||
Integer docId = iter.next();
|
NamedList docNL = new NamedList();
|
||||||
NamedList docNL = new NamedList();
|
termVectors.add("doc-" + docId, docNL);
|
||||||
termVectors.add("doc-" + docId, docNL);
|
mapper.docNL = docNL;
|
||||||
mapper.docNL = docNL;
|
Document document = reader.document(docId, fieldSelector);
|
||||||
Document document = reader.document(docId, fieldSelector);
|
String uniqId = document.get(uniqFieldName);
|
||||||
String uniqId = document.get(uniqFieldName);
|
docNL.add("uniqueKey", uniqId);
|
||||||
docNL.add("uniqueKey", uniqId);
|
reader.getTermFreqVector(docId, mapper);
|
||||||
reader.getTermFreqVector(docId, mapper);
|
|
||||||
}
|
|
||||||
termVectors.add("uniqueKeyFieldName", uniqFieldName);
|
|
||||||
} finally {
|
|
||||||
searcher.decref();
|
|
||||||
}
|
}
|
||||||
|
termVectors.add("uniqueKeyFieldName", uniqFieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> getInts(String[] vals) {
|
private List<Integer> getInts(String[] vals) {
|
||||||
|
|
Loading…
Reference in New Issue