mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-26 06:46:10 +00:00
lucene 4: Upgraded IndexedGeoBoundingBoxFilter & InMemoryGeoBoundingBoxFilter.
This commit is contained in:
parent
d42d153c48
commit
673712c0b2
@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
package org.elasticsearch.index.search.geo;
|
package org.elasticsearch.index.search.geo;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.AtomicReaderContext;
|
||||||
import org.apache.lucene.search.DocIdSet;
|
import org.apache.lucene.search.DocIdSet;
|
||||||
import org.apache.lucene.search.Filter;
|
import org.apache.lucene.search.Filter;
|
||||||
|
import org.apache.lucene.util.Bits;
|
||||||
import org.elasticsearch.common.lucene.docset.GetDocSet;
|
import org.elasticsearch.common.lucene.docset.GetDocSet;
|
||||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||||
import org.elasticsearch.index.mapper.geo.GeoPointFieldData;
|
import org.elasticsearch.index.mapper.geo.GeoPointFieldData;
|
||||||
@ -62,14 +63,14 @@ public class InMemoryGeoBoundingBoxFilter extends Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
|
||||||
final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);
|
final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, context.reader(), fieldName);
|
||||||
|
|
||||||
//checks to see if bounding box crosses 180 degrees
|
//checks to see if bounding box crosses 180 degrees
|
||||||
if (topLeft.lon > bottomRight.lon) {
|
if (topLeft.lon > bottomRight.lon) {
|
||||||
return new Meridian180GeoBoundingBoxDocSet(reader.maxDoc(), fieldData, topLeft, bottomRight);
|
return new Meridian180GeoBoundingBoxDocSet(context.reader().maxDoc(), fieldData, topLeft, bottomRight);
|
||||||
} else {
|
} else {
|
||||||
return new GeoBoundingBoxDocSet(reader.maxDoc(), fieldData, topLeft, bottomRight);
|
return new GeoBoundingBoxDocSet(context.reader().maxDoc(), fieldData, topLeft, bottomRight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
package org.elasticsearch.index.search.geo;
|
package org.elasticsearch.index.search.geo;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.AtomicReaderContext;
|
||||||
import org.apache.lucene.search.DocIdSet;
|
import org.apache.lucene.search.DocIdSet;
|
||||||
import org.apache.lucene.search.Filter;
|
import org.apache.lucene.search.Filter;
|
||||||
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.FixedBitSet;
|
import org.apache.lucene.util.FixedBitSet;
|
||||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||||
import org.elasticsearch.common.lucene.docset.DocSets;
|
import org.elasticsearch.common.lucene.docset.DocSets;
|
||||||
@ -58,16 +59,16 @@ public class IndexedGeoBoundingBoxFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FixedBitSet getDocIdSet(IndexReader reader) throws IOException {
|
public FixedBitSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
|
||||||
FixedBitSet main;
|
FixedBitSet main;
|
||||||
DocIdSet set = lonFilter1.getDocIdSet(reader);
|
DocIdSet set = lonFilter1.getDocIdSet(context, acceptedDocs);
|
||||||
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
||||||
main = null;
|
main = null;
|
||||||
} else {
|
} else {
|
||||||
main = (FixedBitSet) set;
|
main = (FixedBitSet) set;
|
||||||
}
|
}
|
||||||
|
|
||||||
set = lonFilter2.getDocIdSet(reader);
|
set = lonFilter2.getDocIdSet(context, acceptedDocs);
|
||||||
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
||||||
if (main == null) {
|
if (main == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -82,7 +83,7 @@ public class IndexedGeoBoundingBoxFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set = latFilter.getDocIdSet(reader);
|
set = latFilter.getDocIdSet(context, acceptedDocs);
|
||||||
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -124,14 +125,14 @@ public class IndexedGeoBoundingBoxFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FixedBitSet getDocIdSet(IndexReader reader) throws IOException {
|
public FixedBitSet getDocIdSet(AtomicReaderContext context, Bits acceptedDocs) throws IOException {
|
||||||
FixedBitSet main;
|
FixedBitSet main;
|
||||||
DocIdSet set = lonFilter.getDocIdSet(reader);
|
DocIdSet set = lonFilter.getDocIdSet(context, acceptedDocs);
|
||||||
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
main = (FixedBitSet) set;
|
main = (FixedBitSet) set;
|
||||||
set = latFilter.getDocIdSet(reader);
|
set = latFilter.getDocIdSet(context, acceptedDocs);
|
||||||
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
if (set == null || set == DocIdSet.EMPTY_DOCIDSET) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user