lucene 4: Upgraded GeoDistanceFilter, MatchedFiltersFetchSubPhase.
This commit is contained in:
parent
ba1b870580
commit
415cfa2e89
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.index.cache.filter.support;
|
||||
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
package org.elasticsearch.index.search.geo;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.lucene.docset.AndDocSet;
|
||||
import org.elasticsearch.common.lucene.docset.DocSet;
|
||||
|
@ -103,17 +104,17 @@ public class GeoDistanceFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
||||
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
|
||||
DocSet boundingBoxDocSet = null;
|
||||
if (boundingBoxFilter != null) {
|
||||
DocIdSet docIdSet = boundingBoxFilter.getDocIdSet(reader);
|
||||
DocIdSet docIdSet = boundingBoxFilter.getDocIdSet(context, acceptedDocs);
|
||||
if (docIdSet == null) {
|
||||
return null;
|
||||
}
|
||||
boundingBoxDocSet = DocSets.convert(reader, docIdSet);
|
||||
boundingBoxDocSet = DocSets.convert(context.reader(), docIdSet);
|
||||
}
|
||||
final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);
|
||||
GeoDistanceDocSet distDocSet = new GeoDistanceDocSet(reader.maxDoc(), fieldData, fixedSourceDistance, distanceBoundingCheck, distance);
|
||||
final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, context.reader(), fieldName);
|
||||
GeoDistanceDocSet distDocSet = new GeoDistanceDocSet(context.reader().maxDoc(), fieldData, fixedSourceDistance, distanceBoundingCheck, distance);
|
||||
if (boundingBoxDocSet == null) {
|
||||
return distDocSet;
|
||||
} else {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class MatchedFiltersFetchSubPhase implements FetchSubPhase {
|
|||
String name = entry.getKey();
|
||||
Filter filter = entry.getValue();
|
||||
try {
|
||||
DocIdSet docIdSet = filter.getDocIdSet(hitContext.reader());
|
||||
DocIdSet docIdSet = filter.getDocIdSet(hitContext.readerContext(), null); // null is fine, since we filter by hitContext.docId()
|
||||
if (docIdSet != null) {
|
||||
DocSet docSet = DocSets.convert(hitContext.reader(), docIdSet);
|
||||
if (docSet.get(hitContext.docId())) {
|
||||
|
|
|
@ -169,7 +169,7 @@ public class HighlightPhase extends AbstractComponent implements FetchSubPhase {
|
|||
try {
|
||||
SingleFieldVisitor fieldVisitor = new SingleFieldVisitor(mapper.names().indexName());
|
||||
hitContext.reader().document(hitContext.docId(), fieldVisitor);
|
||||
textsToHighlight = (List<Object>) fieldVisitor.values();
|
||||
textsToHighlight = (List) fieldVisitor.values();
|
||||
} catch (Exception e) {
|
||||
throw new FetchPhaseExecutionException(context, "Failed to highlight field [" + field.field() + "]", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue