mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 04:45:37 +00:00
upgrade to lucene 5.5.0-snapshot-850c6c2
This commit is contained in:
parent
df50371c34
commit
52ee4c7027
@ -1,5 +1,5 @@
|
||||
elasticsearch = 3.0.0-SNAPSHOT
|
||||
lucene = 5.5.0-snapshot-4de5f1d
|
||||
lucene = 5.5.0-snapshot-850c6c2
|
||||
|
||||
# optional dependencies
|
||||
spatial4j = 0.5
|
||||
|
@ -20,8 +20,11 @@
|
||||
package org.elasticsearch.common.geo;
|
||||
|
||||
import org.apache.lucene.util.BitUtil;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.mortonEncode;
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.stringEncode;
|
||||
import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonUnhashLat;
|
||||
import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonUnhashLon;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -81,14 +84,14 @@ public final class GeoPoint {
|
||||
}
|
||||
|
||||
public GeoPoint resetFromIndexHash(long hash) {
|
||||
lon = GeoUtils.mortonUnhashLon(hash);
|
||||
lat = GeoUtils.mortonUnhashLat(hash);
|
||||
lon = mortonUnhashLon(hash);
|
||||
lat = mortonUnhashLat(hash);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GeoPoint resetFromGeoHash(String geohash) {
|
||||
final long hash = GeoHashUtils.mortonEncode(geohash);
|
||||
return this.reset(GeoUtils.mortonUnhashLat(hash), GeoUtils.mortonUnhashLon(hash));
|
||||
final long hash = mortonEncode(geohash);
|
||||
return this.reset(mortonUnhashLat(hash), mortonUnhashLon(hash));
|
||||
}
|
||||
|
||||
public GeoPoint resetFromGeoHash(long geohashLong) {
|
||||
@ -113,11 +116,11 @@ public final class GeoPoint {
|
||||
}
|
||||
|
||||
public final String geohash() {
|
||||
return GeoHashUtils.stringEncode(lon, lat);
|
||||
return stringEncode(lon, lat);
|
||||
}
|
||||
|
||||
public final String getGeohash() {
|
||||
return GeoHashUtils.stringEncode(lon, lat);
|
||||
return stringEncode(lon, lat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,6 @@ package org.elasticsearch.common.geo;
|
||||
|
||||
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
||||
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
|
||||
import org.apache.lucene.util.GeoDistanceUtils;
|
||||
import org.apache.lucene.util.SloppyMath;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
@ -29,6 +28,8 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoDistanceUtils.maxRadialDistanceMeters;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -70,7 +71,7 @@ public class GeoUtils {
|
||||
* maximum distance/radius from the point 'center' before overlapping
|
||||
**/
|
||||
public static double maxRadialDistance(GeoPoint center, double initialRadius) {
|
||||
final double maxRadius = GeoDistanceUtils.maxRadialDistanceMeters(center.lon(), center.lat());
|
||||
final double maxRadius = maxRadialDistanceMeters(center.lon(), center.lat());
|
||||
return Math.min(initialRadius, maxRadius);
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,12 @@
|
||||
|
||||
package org.elasticsearch.index.fielddata.plain;
|
||||
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.BytesRefIterator;
|
||||
import org.apache.lucene.util.CharsRefBuilder;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
@ -45,7 +47,7 @@ abstract class AbstractIndexGeoPointFieldData extends AbstractIndexFieldData<Ato
|
||||
}
|
||||
|
||||
protected static class GeoPointTermsEnum extends BaseGeoPointTermsEnum {
|
||||
protected GeoPointTermsEnum(BytesRefIterator termsEnum) {
|
||||
protected GeoPointTermsEnum(BytesRefIterator termsEnum, GeoPointField.TermEncoding termEncoding) {
|
||||
super(termsEnum);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.index.RandomAccessOrds;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
@ -48,25 +49,20 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
*/
|
||||
public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData {
|
||||
private final CircuitBreakerService breakerService;
|
||||
private final boolean indexCreatedBefore22;
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new GeoPointArrayIndexFieldData(indexSettings, fieldType.name(), fieldType.fieldDataType(), cache,
|
||||
breakerService, fieldType.fieldDataType().getSettings()
|
||||
.getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).before(Version.V_2_2_0) ||
|
||||
indexSettings.getIndexVersionCreated().before(Version.V_2_2_0));
|
||||
breakerService);
|
||||
}
|
||||
}
|
||||
|
||||
public GeoPointArrayIndexFieldData(IndexSettings indexSettings, String fieldName,
|
||||
FieldDataType fieldDataType, IndexFieldDataCache cache, CircuitBreakerService breakerService,
|
||||
final boolean indexCreatedBefore22) {
|
||||
FieldDataType fieldDataType, IndexFieldDataCache cache, CircuitBreakerService breakerService) {
|
||||
super(indexSettings, fieldName, fieldDataType, cache);
|
||||
this.breakerService = breakerService;
|
||||
this.indexCreatedBefore22 = indexCreatedBefore22;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +78,8 @@ public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData
|
||||
estimator.afterLoad(null, data.ramBytesUsed());
|
||||
return data;
|
||||
}
|
||||
return (indexCreatedBefore22 == true) ? loadLegacyFieldData(reader, estimator, terms, data) : loadFieldData22(reader, estimator, terms, data);
|
||||
return (indexSettings.getIndexVersionCreated().before(Version.V_2_2_0) == true) ?
|
||||
loadLegacyFieldData(reader, estimator, terms, data) : loadFieldData22(reader, estimator, terms, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +92,9 @@ public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData
|
||||
OrdinalsBuilder.DEFAULT_ACCEPTABLE_OVERHEAD_RATIO);
|
||||
boolean success = false;
|
||||
try (OrdinalsBuilder builder = new OrdinalsBuilder(reader.maxDoc(), acceptableTransientOverheadRatio)) {
|
||||
final GeoPointTermsEnum iter = new GeoPointTermsEnum(builder.buildFromTerms(OrdinalsBuilder.wrapNumeric64Bit(terms.iterator())));
|
||||
final GeoPointField.TermEncoding termEncoding = indexSettings.getIndexVersionCreated().onOrAfter(Version.V_2_3_0) ?
|
||||
GeoPointField.TermEncoding.PREFIX : GeoPointField.TermEncoding.NUMERIC;
|
||||
final GeoPointTermsEnum iter = new GeoPointTermsEnum(builder.buildFromTerms(OrdinalsBuilder.wrapNumeric64Bit(terms.iterator())), termEncoding);
|
||||
Long hashedPoint;
|
||||
long numTerms = 0;
|
||||
while ((hashedPoint = iter.next()) != null) {
|
||||
@ -181,4 +180,4 @@ public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ package org.elasticsearch.index.mapper.geo;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Explicit;
|
||||
@ -29,7 +30,6 @@ import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.Iterators;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -20,9 +20,10 @@
|
||||
package org.elasticsearch.index.mapper.geo;
|
||||
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.GeoPointField;
|
||||
import org.apache.lucene.index.DocValuesType;
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Explicit;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
@ -59,8 +60,6 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper {
|
||||
FIELD_TYPE.setIndexOptions(IndexOptions.DOCS);
|
||||
FIELD_TYPE.setTokenized(false);
|
||||
FIELD_TYPE.setOmitNorms(true);
|
||||
FIELD_TYPE.setNumericType(FieldType.NumericType.LONG);
|
||||
FIELD_TYPE.setNumericPrecisionStep(GeoPointField.PRECISION_STEP);
|
||||
FIELD_TYPE.setDocValuesType(DocValuesType.SORTED_NUMERIC);
|
||||
FIELD_TYPE.setHasDocValues(true);
|
||||
FIELD_TYPE.freeze();
|
||||
@ -83,6 +82,10 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper {
|
||||
DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
||||
CopyTo copyTo) {
|
||||
fieldType.setTokenized(false);
|
||||
if (context.indexCreatedVersion().before(Version.V_2_3_0)) {
|
||||
fieldType.setNumericPrecisionStep(GeoPointField.PRECISION_STEP);
|
||||
fieldType.setNumericType(FieldType.NumericType.LONG);
|
||||
}
|
||||
setupFieldType(context);
|
||||
return new GeoPointFieldMapper(simpleName, fieldType, defaultFieldType, indexSettings, latMapper, lonMapper,
|
||||
geoHashMapper, multiFields, ignoreMalformed, copyTo);
|
||||
@ -90,6 +93,10 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper {
|
||||
|
||||
@Override
|
||||
public GeoPointFieldMapper build(BuilderContext context) {
|
||||
if (context.indexCreatedVersion().before(Version.V_2_3_0)) {
|
||||
fieldType.setNumericPrecisionStep(GeoPointField.PRECISION_STEP);
|
||||
fieldType.setNumericType(FieldType.NumericType.LONG);
|
||||
}
|
||||
return super.build(context);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.GeoPointInBBoxQuery;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
@ -105,7 +106,7 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
|
||||
|
||||
// we do not check longitudes as the query generation code can deal with flipped left/right values
|
||||
}
|
||||
|
||||
|
||||
topLeft.reset(top, left);
|
||||
bottomRight.reset(bottom, right);
|
||||
return this;
|
||||
@ -133,7 +134,7 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
|
||||
public GeoPoint topLeft() {
|
||||
return topLeft;
|
||||
}
|
||||
|
||||
|
||||
/** Returns the bottom right corner of the bounding box. */
|
||||
public GeoPoint bottomRight() {
|
||||
return bottomRight;
|
||||
@ -168,7 +169,7 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
|
||||
this.validationMethod = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns geo coordinate validation method to use.
|
||||
* */
|
||||
@ -264,8 +265,13 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
|
||||
}
|
||||
}
|
||||
|
||||
if (context.indexVersionCreated().onOrAfter(Version.V_2_2_0)) {
|
||||
return new GeoPointInBBoxQuery(fieldType.name(), luceneTopLeft.lon(), luceneBottomRight.lat(),
|
||||
final Version indexVersionCreated = context.indexVersionCreated();
|
||||
if (indexVersionCreated.onOrAfter(Version.V_2_2_0)) {
|
||||
// if index created V_2_2 use (soon to be legacy) numeric encoding postings format
|
||||
// if index created V_2_3 > use prefix encoded postings format
|
||||
final GeoPointField.TermEncoding encoding = (indexVersionCreated.before(Version.V_2_3_0)) ?
|
||||
GeoPointField.TermEncoding.NUMERIC : GeoPointField.TermEncoding.PREFIX;
|
||||
return new GeoPointInBBoxQuery(fieldType.name(), encoding, luceneTopLeft.lon(), luceneBottomRight.lat(),
|
||||
luceneBottomRight.lon(), luceneTopLeft.lat());
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.GeoPointDistanceQuery;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointDistanceQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Strings;
|
||||
@ -229,14 +230,19 @@ public class GeoDistanceQueryBuilder extends AbstractQueryBuilder<GeoDistanceQue
|
||||
|
||||
double normDistance = geoDistance.normalize(this.distance, DistanceUnit.DEFAULT);
|
||||
|
||||
if (shardContext.indexVersionCreated().before(Version.V_2_2_0)) {
|
||||
final Version indexVersionCreated = shardContext.indexVersionCreated();
|
||||
if (indexVersionCreated.before(Version.V_2_2_0)) {
|
||||
GeoPointFieldMapperLegacy.GeoPointFieldType geoFieldType = ((GeoPointFieldMapperLegacy.GeoPointFieldType) fieldType);
|
||||
IndexGeoPointFieldData indexFieldData = shardContext.getForField(fieldType);
|
||||
return new GeoDistanceRangeQuery(center, null, normDistance, true, false, geoDistance, geoFieldType, indexFieldData, optimizeBbox);
|
||||
}
|
||||
|
||||
// if index created V_2_2 use (soon to be legacy) numeric encoding postings format
|
||||
// if index created V_2_3 > use prefix encoded postings format
|
||||
final GeoPointField.TermEncoding encoding = (indexVersionCreated.before(Version.V_2_3_0)) ?
|
||||
GeoPointField.TermEncoding.NUMERIC : GeoPointField.TermEncoding.PREFIX;
|
||||
normDistance = GeoUtils.maxRadialDistance(center, normDistance);
|
||||
return new GeoPointDistanceQuery(fieldType.name(), center.lon(), center.lat(), normDistance);
|
||||
return new GeoPointDistanceQuery(fieldType.name(), encoding, center.lon(), center.lat(), normDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,9 +19,10 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.GeoPointDistanceRangeQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.GeoDistanceUtils;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointDistanceRangeQuery;
|
||||
import org.apache.lucene.spatial.util.GeoDistanceUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.geo.GeoDistance;
|
||||
@ -41,7 +42,7 @@ import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.apache.lucene.util.GeoUtils.TOLERANCE;
|
||||
import static org.apache.lucene.spatial.util.GeoEncodingUtils.TOLERANCE;
|
||||
|
||||
public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistanceRangeQueryBuilder> {
|
||||
|
||||
@ -267,16 +268,22 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
|
||||
toValue = GeoDistanceUtils.maxRadialDistanceMeters(point.lon(), point.lat());
|
||||
}
|
||||
|
||||
if (indexCreatedBeforeV2_2 == true) {
|
||||
final Version indexVersionCreated = context.indexVersionCreated();
|
||||
if (indexVersionCreated.before(Version.V_2_2_0)) {
|
||||
GeoPointFieldMapperLegacy.GeoPointFieldType geoFieldType = ((GeoPointFieldMapperLegacy.GeoPointFieldType) fieldType);
|
||||
IndexGeoPointFieldData indexFieldData = context.getForField(fieldType);
|
||||
return new GeoDistanceRangeQuery(point, fromValue, toValue, includeLower, includeUpper, geoDistance, geoFieldType,
|
||||
indexFieldData, optimizeBbox);
|
||||
indexFieldData, optimizeBbox);
|
||||
}
|
||||
|
||||
return new GeoPointDistanceRangeQuery(fieldType.name(), point.lon(), point.lat(),
|
||||
(includeLower) ? fromValue : fromValue + TOLERANCE,
|
||||
(includeUpper) ? toValue : toValue - TOLERANCE);
|
||||
// if index created V_2_2 use (soon to be legacy) numeric encoding postings format
|
||||
// if index created V_2_3 > use prefix encoded postings format
|
||||
final GeoPointField.TermEncoding encoding = (indexVersionCreated.before(Version.V_2_3_0)) ?
|
||||
GeoPointField.TermEncoding.NUMERIC : GeoPointField.TermEncoding.PREFIX;
|
||||
|
||||
return new GeoPointDistanceRangeQuery(fieldType.name(), encoding, point.lon(), point.lat(),
|
||||
(includeLower) ? fromValue : fromValue + TOLERANCE,
|
||||
(includeUpper) ? toValue : toValue - TOLERANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.GeoPointInPolygonQuery;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointInPolygonQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Strings;
|
||||
@ -136,7 +137,8 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder<GeoPolygonQuery
|
||||
}
|
||||
}
|
||||
|
||||
if (context.indexVersionCreated().before(Version.V_2_2_0)) {
|
||||
final Version indexVersionCreated = context.indexVersionCreated();
|
||||
if (indexVersionCreated.before(Version.V_2_2_0)) {
|
||||
IndexGeoPointFieldData indexFieldData = context.getForField(fieldType);
|
||||
return new GeoPolygonQuery(indexFieldData, shell.toArray(new GeoPoint[shellSize]));
|
||||
}
|
||||
@ -149,7 +151,11 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder<GeoPolygonQuery
|
||||
lats[i] = p.lat();
|
||||
lons[i] = p.lon();
|
||||
}
|
||||
return new GeoPointInPolygonQuery(fieldType.name(), lons, lats);
|
||||
// if index created V_2_2 use (soon to be legacy) numeric encoding postings format
|
||||
// if index created V_2_3 > use prefix encoded postings format
|
||||
final GeoPointField.TermEncoding encoding = (indexVersionCreated.before(Version.V_2_3_0)) ?
|
||||
GeoPointField.TermEncoding.NUMERIC : GeoPointField.TermEncoding.PREFIX;
|
||||
return new GeoPointInPolygonQuery(fieldType.name(), encoding, lons, lats);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
|
@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations.bucket.geogrid;
|
||||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.index.SortedNumericDocValues;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.bucket.geogrid;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.PriorityQueue;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.search.aggregations.metrics.geocentroid;
|
||||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.apache.lucene.spatial.util.GeoEncodingUtils;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.lease.Releasables;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
@ -95,7 +95,7 @@ public final class GeoCentroidAggregator extends MetricsAggregator {
|
||||
pt[0] = pt[0] + (value.getLon() - pt[0]) / ++prevCounts;
|
||||
pt[1] = pt[1] + (value.getLat() - pt[1]) / prevCounts;
|
||||
}
|
||||
centroids.set(bucket, GeoUtils.mortonHash(pt[0], pt[1]));
|
||||
centroids.set(bucket, GeoEncodingUtils.mortonHash(pt[0], pt[1]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.search.aggregations.metrics.geocentroid;
|
||||
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.apache.lucene.spatial.util.GeoEncodingUtils;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
@ -140,7 +140,7 @@ public class InternalGeoCentroid extends InternalMetricsAggregation implements G
|
||||
out.writeVLong(count);
|
||||
if (centroid != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeLong(GeoUtils.mortonHash(centroid.lon(), centroid.lat()));
|
||||
out.writeLong(GeoEncodingUtils.mortonHash(centroid.lon(), centroid.lat()));
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.support.format;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
@ -22,7 +22,6 @@ package org.elasticsearch.search.suggest.completion.context;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.index.DocValuesType;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
@ -44,6 +43,9 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.addNeighbors;
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.stringEncode;
|
||||
|
||||
/**
|
||||
* A {@link ContextMapping} that uses a geo location/area as a
|
||||
* criteria.
|
||||
@ -150,7 +152,7 @@ public class GeoContextMapping extends ContextMapping {
|
||||
if (parser.nextToken() == Token.VALUE_NUMBER) {
|
||||
double lat = parser.doubleValue();
|
||||
if (parser.nextToken() == Token.END_ARRAY) {
|
||||
contexts.add(GeoHashUtils.stringEncode(lon, lat, precision));
|
||||
contexts.add(stringEncode(lon, lat, precision));
|
||||
} else {
|
||||
throw new ElasticsearchParseException("only two values [lon, lat] expected");
|
||||
}
|
||||
@ -160,7 +162,7 @@ public class GeoContextMapping extends ContextMapping {
|
||||
} else {
|
||||
while (token != Token.END_ARRAY) {
|
||||
GeoPoint point = GeoUtils.parseGeoPoint(parser);
|
||||
contexts.add(GeoHashUtils.stringEncode(point.getLon(), point.getLat(), precision));
|
||||
contexts.add(stringEncode(point.getLon(), point.getLat(), precision));
|
||||
token = parser.nextToken();
|
||||
}
|
||||
}
|
||||
@ -171,7 +173,7 @@ public class GeoContextMapping extends ContextMapping {
|
||||
} else {
|
||||
// or a single location
|
||||
GeoPoint point = GeoUtils.parseGeoPoint(parser);
|
||||
contexts.add(GeoHashUtils.stringEncode(point.getLon(), point.getLat(), precision));
|
||||
contexts.add(stringEncode(point.getLon(), point.getLat(), precision));
|
||||
}
|
||||
return contexts;
|
||||
}
|
||||
@ -194,7 +196,7 @@ public class GeoContextMapping extends ContextMapping {
|
||||
// we write doc values fields differently: one field for all values, so we need to only care about indexed fields
|
||||
if (lonField.fieldType().docValuesType() == DocValuesType.NONE) {
|
||||
spare.reset(latField.numericValue().doubleValue(), lonField.numericValue().doubleValue());
|
||||
geohashes.add(GeoHashUtils.stringEncode(spare.getLon(), spare.getLat(), precision));
|
||||
geohashes.add(stringEncode(spare.getLon(), spare.getLat(), precision));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -261,16 +263,16 @@ public class GeoContextMapping extends ContextMapping {
|
||||
}
|
||||
GeoPoint point = queryContext.getGeoPoint();
|
||||
final Collection<String> locations = new HashSet<>();
|
||||
String geoHash = GeoHashUtils.stringEncode(point.getLon(), point.getLat(), minPrecision);
|
||||
String geoHash = stringEncode(point.getLon(), point.getLat(), minPrecision);
|
||||
locations.add(geoHash);
|
||||
if (queryContext.getNeighbours().isEmpty() && geoHash.length() == this.precision) {
|
||||
GeoHashUtils.addNeighbors(geoHash, locations);
|
||||
addNeighbors(geoHash, locations);
|
||||
} else if (queryContext.getNeighbours().isEmpty() == false) {
|
||||
for (Integer neighbourPrecision : queryContext.getNeighbours()) {
|
||||
if (neighbourPrecision < geoHash.length()) {
|
||||
String truncatedGeoHash = geoHash.substring(0, neighbourPrecision);
|
||||
locations.add(truncatedGeoHash);
|
||||
GeoHashUtils.addNeighbors(truncatedGeoHash, locations);
|
||||
addNeighbors(truncatedGeoHash, locations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ grant codeBase "${codebase.securesm-1.0.jar}" {
|
||||
//// Very special jar permissions:
|
||||
//// These are dangerous permissions that we don't want to grant to everything.
|
||||
|
||||
grant codeBase "${codebase.lucene-core-5.5.0-snapshot-4de5f1d.jar}" {
|
||||
grant codeBase "${codebase.lucene-core-5.5.0-snapshot-850c6c2.jar}" {
|
||||
// needed to allow MMapDirectory's "unmap hack" (die unmap hack, die)
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
|
||||
|
@ -31,7 +31,7 @@ grant codeBase "${codebase.securemock-1.2.jar}" {
|
||||
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
|
||||
};
|
||||
|
||||
grant codeBase "${codebase.lucene-test-framework-5.5.0-snapshot-4de5f1d.jar}" {
|
||||
grant codeBase "${codebase.lucene-test-framework-5.5.0-snapshot-850c6c2.jar}" {
|
||||
// needed by RamUsageTester
|
||||
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
|
||||
};
|
||||
|
@ -18,13 +18,11 @@
|
||||
*/
|
||||
package org.elasticsearch.common.geo;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests for {@link org.apache.lucene.util.GeoHashUtils}
|
||||
* Tests for {@link org.apache.lucene.spatial.util.GeoHashUtils}
|
||||
*/
|
||||
public class GeoHashTests extends ESTestCase {
|
||||
public void testGeohashAsLongRoutines() {
|
||||
@ -60,4 +58,4 @@ public class GeoHashTests extends ESTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ package org.elasticsearch.index.fielddata;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.GeoPointField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
||||
import org.apache.lucene.spatial.util.GeoUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
|
||||
@ -45,7 +45,27 @@ public abstract class AbstractGeoFieldDataTestCase extends AbstractFieldDataImpl
|
||||
if (indexService.getIndexSettings().getIndexVersionCreated().before(Version.V_2_2_0)) {
|
||||
return new StringField(fieldName, point.lat()+","+point.lon(), store);
|
||||
}
|
||||
return new GeoPointField(fieldName, point.lon(), point.lat(), store);
|
||||
final GeoPointField.TermEncoding termEncoding;
|
||||
termEncoding = indexService.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_2_3_0) ?
|
||||
GeoPointField.TermEncoding.PREFIX : GeoPointField.TermEncoding.NUMERIC;
|
||||
return new GeoPointField(fieldName, point.lon(), point.lat(), termEncoding, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasDocValues() {
|
||||
// prior to 22 docValues were not required
|
||||
if (indexService.getIndexSettings().getIndexVersionCreated().before(Version.V_2_2_0)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long minRamBytesUsed() {
|
||||
if (indexService.getIndexSettings().getIndexVersionCreated().before(Version.V_2_2_0)) {
|
||||
return super.minRamBytesUsed();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.mapper.externalvalues;
|
||||
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.apache.lucene.spatial.util.GeoEncodingUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
@ -88,7 +88,7 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getField("field.point").stringValue(), is("42.0,51.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoUtils.mortonHash(51.0, 42.0)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoEncodingUtils.mortonHash(51.0, 42.0)));
|
||||
}
|
||||
|
||||
assertThat(doc.rootDoc().getField("field.shape"), notNullValue());
|
||||
@ -146,7 +146,7 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getField("field.point").stringValue(), is("42.0,51.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoUtils.mortonHash(51.0, 42.0)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoEncodingUtils.mortonHash(51.0, 42.0)));
|
||||
}
|
||||
|
||||
assertThat(doc.rootDoc().getField("field.shape"), notNullValue());
|
||||
@ -208,7 +208,7 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getField("field.point").stringValue(), is("42.0,51.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoUtils.mortonHash(51.0, 42.0)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoEncodingUtils.mortonHash(51.0, 42.0)));
|
||||
}
|
||||
|
||||
assertThat(doc.rootDoc().getField("field.shape"), notNullValue());
|
||||
|
@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.index.mapper.geo;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
@ -46,6 +44,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonHash;
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.stringEncode;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
@ -86,7 +86,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (indexCreatedBefore22 == true) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
|
||||
assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.stringEncode(1.3, 1.2)));
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(stringEncode(1.3, 1.2)));
|
||||
}
|
||||
|
||||
public void testLatLonInOneValueWithGeohash() throws Exception {
|
||||
@ -128,7 +128,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
|
||||
assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.stringEncode(1.3, 1.2)));
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(stringEncode(1.3, 1.2)));
|
||||
}
|
||||
|
||||
public void testGeoHashIndexValue() throws Exception {
|
||||
@ -142,13 +142,13 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.field("point", GeoHashUtils.stringEncode(1.3, 1.2))
|
||||
.field("point", stringEncode(1.3, 1.2))
|
||||
.endObject()
|
||||
.bytes());
|
||||
|
||||
assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.stringEncode(1.3, 1.2)));
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(stringEncode(1.3, 1.2)));
|
||||
}
|
||||
|
||||
public void testGeoHashValue() throws Exception {
|
||||
@ -162,7 +162,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.field("point", GeoHashUtils.stringEncode(1.3, 1.2))
|
||||
.field("point", stringEncode(1.3, 1.2))
|
||||
.endObject()
|
||||
.bytes());
|
||||
|
||||
@ -193,7 +193,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("89.0,1.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(1.0, 89.0)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(1.0, 89.0)));
|
||||
}
|
||||
|
||||
doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
@ -205,7 +205,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("-89.0,-1.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(-1.0, -89.0)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(-1.0, -89.0)));
|
||||
}
|
||||
|
||||
doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
@ -217,7 +217,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("-1.0,-179.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(-179.0, -1.0)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(-179.0, -1.0)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,14 +379,14 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getFields("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
assertThat(doc.rootDoc().getFields("point.lat")[1].numericValue().doubleValue(), equalTo(1.4));
|
||||
assertThat(doc.rootDoc().getFields("point.lon")[1].numericValue().doubleValue(), equalTo(1.5));
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(GeoUtils.mortonHash(1.5, 1.4)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(mortonHash(1.5, 1.4)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,14 +465,14 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getFields("point")[0].stringValue(), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
assertThat(doc.rootDoc().getFields("point.lat")[1].numericValue().doubleValue(), equalTo(1.4));
|
||||
assertThat(doc.rootDoc().getFields("point.lon")[1].numericValue().doubleValue(), equalTo(1.5));
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(GeoUtils.mortonHash(1.5, 1.4)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(mortonHash(1.5, 1.4)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,7 +521,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,14 +576,14 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
assertThat(doc.rootDoc().getFields("point.lat")[1].numericValue().doubleValue(), equalTo(1.4));
|
||||
assertThat(doc.rootDoc().getFields("point.lon")[1].numericValue().doubleValue(), equalTo(1.5));
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(GeoUtils.mortonHash(1.5, 1.4)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(mortonHash(1.5, 1.4)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.elasticsearch.index.mapper.geo;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
@ -36,6 +34,8 @@ import org.elasticsearch.test.VersionUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.stringEncode;
|
||||
import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonHash;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@ -72,7 +72,7 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoUtils.mortonHash(1.3, 1.2)));
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(mortonHash(1.3, 1.2)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,13 +111,13 @@ public class GeohashMappingGeoPointTests extends ESSingleNodeTestCase {
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.field("point", GeoHashUtils.stringEncode(1.3, 1.2))
|
||||
.field("point", stringEncode(1.3, 1.2))
|
||||
.endObject()
|
||||
.bytes());
|
||||
|
||||
assertThat(doc.rootDoc().getField("point.lat"), nullValue());
|
||||
assertThat(doc.rootDoc().getField("point.lon"), nullValue());
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.stringEncode(1.3, 1.2)));
|
||||
assertThat(doc.rootDoc().get("point.geohash"), equalTo(stringEncode(1.3, 1.2)));
|
||||
assertThat(doc.rootDoc().get("point"), notNullValue());
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,9 @@ package org.elasticsearch.index.mapper.multifield;
|
||||
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
@ -38,15 +34,11 @@ import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.ParseContext.Document;
|
||||
import org.elasticsearch.index.mapper.core.CompletionFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.TokenCountFieldMapper;
|
||||
import org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.object.RootObjectMapper;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
import org.elasticsearch.test.VersionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
@ -24,9 +24,9 @@ import com.spatial4j.core.shape.Rectangle;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.GeoPointInBBoxQuery;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
|
@ -20,9 +20,9 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import com.spatial4j.core.shape.Point;
|
||||
import org.apache.lucene.search.GeoPointDistanceQuery;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointDistanceQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.apache.lucene.spatial.util.GeoEncodingUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.geo.GeoDistance;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
@ -205,7 +205,7 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
|
||||
if (queryBuilder.geoDistance() != null) {
|
||||
distance = queryBuilder.geoDistance().normalize(distance, DistanceUnit.DEFAULT);
|
||||
distance = org.elasticsearch.common.geo.GeoUtils.maxRadialDistance(queryBuilder.point(), distance);
|
||||
assertThat(geoQuery.getRadiusMeters(), closeTo(distance, GeoUtils.TOLERANCE));
|
||||
assertThat(geoQuery.getRadiusMeters(), closeTo(distance, GeoEncodingUtils.TOLERANCE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.GeoPointDistanceRangeQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.GeoDistanceUtils;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointDistanceRangeQuery;
|
||||
import org.apache.lucene.spatial.util.GeoDistanceUtils;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.geo.GeoDistance;
|
||||
|
@ -21,8 +21,8 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import com.spatial4j.core.shape.jts.JtsGeometry;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import org.apache.lucene.search.GeoPointInPolygonQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.spatial.geopoint.search.GeoPointInPolygonQuery;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.index.search.geo;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
@ -32,7 +31,7 @@ import org.elasticsearch.test.geo.RandomGeoGenerator;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.stringEncode;
|
||||
|
||||
public class GeoPointParsingTests extends ESTestCase {
|
||||
static double TOLERANCE = 1E-5;
|
||||
@ -51,7 +50,7 @@ public class GeoPointParsingTests extends ESTestCase {
|
||||
assertPointsEqual(point.resetLat(0), point2.reset(0, 0));
|
||||
assertPointsEqual(point.resetLon(lon), point2.reset(0, lon));
|
||||
assertPointsEqual(point.resetLon(0), point2.reset(0, 0));
|
||||
assertCloseTo(point.resetFromGeoHash(GeoHashUtils.stringEncode(lon, lat)), lat, lon);
|
||||
assertCloseTo(point.resetFromGeoHash(stringEncode(lon, lat)), lat, lon);
|
||||
assertPointsEqual(point.reset(0, 0), point2.reset(0, 0));
|
||||
assertPointsEqual(point.resetFromString(Double.toString(lat) + ", " + Double.toHexString(lon)), point2.reset(lat, lon));
|
||||
assertPointsEqual(point.reset(0, 0), point2.reset(0, 0));
|
||||
@ -125,7 +124,7 @@ public class GeoPointParsingTests extends ESTestCase {
|
||||
public void testInvalidPointLatHashMix() throws IOException {
|
||||
XContentBuilder content = JsonXContent.contentBuilder();
|
||||
content.startObject();
|
||||
content.field("lat", 0).field("geohash", GeoHashUtils.stringEncode(0d, 0d));
|
||||
content.field("lat", 0).field("geohash", stringEncode(0d, 0d));
|
||||
content.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
|
||||
@ -142,7 +141,7 @@ public class GeoPointParsingTests extends ESTestCase {
|
||||
public void testInvalidPointLonHashMix() throws IOException {
|
||||
XContentBuilder content = JsonXContent.contentBuilder();
|
||||
content.startObject();
|
||||
content.field("lon", 0).field("geohash", GeoHashUtils.stringEncode(0d, 0d));
|
||||
content.field("lon", 0).field("geohash", stringEncode(0d, 0d));
|
||||
content.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
|
||||
@ -201,7 +200,7 @@ public class GeoPointParsingTests extends ESTestCase {
|
||||
|
||||
private static XContentParser geohash(double lat, double lon) throws IOException {
|
||||
XContentBuilder content = JsonXContent.contentBuilder();
|
||||
content.value(GeoHashUtils.stringEncode(lon, lat));
|
||||
content.value(stringEncode(lon, lat));
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(content.bytes());
|
||||
parser.nextToken();
|
||||
return parser;
|
||||
|
@ -24,7 +24,7 @@ import com.spatial4j.core.distance.DistanceUtils;
|
||||
import org.apache.lucene.spatial.prefix.tree.Cell;
|
||||
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
||||
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
|
@ -21,7 +21,6 @@ package org.elasticsearch.search.aggregations.bucket;
|
||||
import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||
import com.carrotsearch.hppc.ObjectIntMap;
|
||||
import com.carrotsearch.hppc.cursors.ObjectIntCursor;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
@ -47,6 +46,8 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.PRECISION;
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.stringEncode;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.search.aggregations.AggregationBuilders.geohashGrid;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
@ -99,13 +100,13 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
//generate random point
|
||||
double lat = (180d * random.nextDouble()) - 90d;
|
||||
double lng = (360d * random.nextDouble()) - 180d;
|
||||
String randomGeoHash = GeoHashUtils.stringEncode(lng, lat, GeoHashUtils.PRECISION);
|
||||
String randomGeoHash = stringEncode(lng, lat, PRECISION);
|
||||
//Index at the highest resolution
|
||||
cities.add(indexCity("idx", randomGeoHash, lat + ", " + lng));
|
||||
expectedDocCountsForGeoHash.put(randomGeoHash, expectedDocCountsForGeoHash.getOrDefault(randomGeoHash, 0) + 1);
|
||||
//Update expected doc counts for all resolutions..
|
||||
for (int precision = GeoHashUtils.PRECISION - 1; precision > 0; precision--) {
|
||||
String hash = GeoHashUtils.stringEncode(lng, lat, precision);
|
||||
for (int precision = PRECISION - 1; precision > 0; precision--) {
|
||||
String hash = stringEncode(lng, lat, precision);
|
||||
if ((smallestGeoHash == null) || (hash.length() < smallestGeoHash.length())) {
|
||||
smallestGeoHash = hash;
|
||||
}
|
||||
@ -128,8 +129,8 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
double lng = (360d * random.nextDouble()) - 180d;
|
||||
points.add(lat + "," + lng);
|
||||
// Update expected doc counts for all resolutions..
|
||||
for (int precision = GeoHashUtils.PRECISION; precision > 0; precision--) {
|
||||
final String geoHash = GeoHashUtils.stringEncode(lng, lat, precision);
|
||||
for (int precision = PRECISION; precision > 0; precision--) {
|
||||
final String geoHash = stringEncode(lng, lat, precision);
|
||||
geoHashes.add(geoHash);
|
||||
}
|
||||
}
|
||||
@ -144,7 +145,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(geohashGrid("geohashgrid")
|
||||
.field("location")
|
||||
@ -168,14 +169,14 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
assertEquals("Geohash " + geohash + " has wrong doc count ",
|
||||
expectedBucketCount, bucketCount);
|
||||
GeoPoint geoPoint = (GeoPoint) propertiesKeys[i];
|
||||
assertThat(GeoHashUtils.stringEncode(geoPoint.lon(), geoPoint.lat(), precision), equalTo(geohash));
|
||||
assertThat(stringEncode(geoPoint.lon(), geoPoint.lat(), precision), equalTo(geohash));
|
||||
assertThat((long) propertiesDocCounts[i], equalTo(bucketCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testMultivalued() throws Exception {
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
SearchResponse response = client().prepareSearch("multi_valued_idx")
|
||||
.addAggregation(geohashGrid("geohashgrid")
|
||||
.field("location")
|
||||
@ -201,7 +202,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
public void testFiltered() throws Exception {
|
||||
GeoBoundingBoxQueryBuilder bbox = new GeoBoundingBoxQueryBuilder("location");
|
||||
bbox.setCorners(smallestGeoHash, smallestGeoHash).queryName("bbox");
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(
|
||||
AggregationBuilders.filter("filtered").filter(bbox)
|
||||
@ -232,7 +233,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
public void testUnmapped() throws Exception {
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
SearchResponse response = client().prepareSearch("idx_unmapped")
|
||||
.addAggregation(geohashGrid("geohashgrid")
|
||||
.field("location")
|
||||
@ -249,7 +250,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
public void testPartiallyUnmapped() throws Exception {
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
|
||||
.addAggregation(geohashGrid("geohashgrid")
|
||||
.field("location")
|
||||
@ -273,7 +274,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
public void testTopMatch() throws Exception {
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(geohashGrid("geohashgrid")
|
||||
.field("location")
|
||||
@ -306,7 +307,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||
|
||||
// making sure this doesn't runs into an OOME
|
||||
public void testSizeIsZero() {
|
||||
for (int precision = 1; precision <= GeoHashUtils.PRECISION; precision++) {
|
||||
for (int precision = 1; precision <= PRECISION; precision++) {
|
||||
final int size = randomBoolean() ? 0 : randomIntBetween(1, Integer.MAX_VALUE);
|
||||
final int shardSize = randomBoolean() ? -1 : 0;
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.bucket;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -23,7 +23,7 @@ import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||
import com.carrotsearch.hppc.ObjectIntMap;
|
||||
import com.carrotsearch.hppc.ObjectObjectHashMap;
|
||||
import com.carrotsearch.hppc.ObjectObjectMap;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
|
@ -29,8 +29,8 @@ import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
||||
import org.apache.lucene.spatial.query.SpatialArgs;
|
||||
import org.apache.lucene.spatial.query.SpatialOperation;
|
||||
import org.apache.lucene.spatial.query.UnsupportedSpatialOperation;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.GeoProjectionUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoProjectionUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.search.sort;
|
||||
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
@ -34,8 +34,6 @@ import org.elasticsearch.index.query.GeoDistanceQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||
import org.elasticsearch.test.VersionUtils;
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.elasticsearch.search.suggest;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.suggest.SuggestResponse;
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.elasticsearch.search.suggest.completion;
|
||||
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.util.GeoHashUtils;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
@ -39,6 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.lucene.spatial.util.GeoHashUtils.addNeighbors;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.search.suggest.completion.CategoryContextMappingTests.assertContextSuggestFields;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@ -206,7 +206,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
|
||||
assertThat(queryContexts.size(), equalTo(1 + 8));
|
||||
Collection<String> locations = new ArrayList<>();
|
||||
locations.add("ezs42e");
|
||||
GeoHashUtils.addNeighbors("ezs42e", GeoContextMapping.DEFAULT_PRECISION, locations);
|
||||
addNeighbors("ezs42e", GeoContextMapping.DEFAULT_PRECISION, locations);
|
||||
for (ContextMapping.QueryContext queryContext : queryContexts) {
|
||||
assertThat(queryContext.context, isIn(locations));
|
||||
assertThat(queryContext.boost, equalTo(1));
|
||||
@ -225,7 +225,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
|
||||
assertThat(queryContexts.size(), equalTo(1 + 8));
|
||||
Collection<String> locations = new ArrayList<>();
|
||||
locations.add("wh0n94");
|
||||
GeoHashUtils.addNeighbors("wh0n94", GeoContextMapping.DEFAULT_PRECISION, locations);
|
||||
addNeighbors("wh0n94", GeoContextMapping.DEFAULT_PRECISION, locations);
|
||||
for (ContextMapping.QueryContext queryContext : queryContexts) {
|
||||
assertThat(queryContext.context, isIn(locations));
|
||||
assertThat(queryContext.boost, equalTo(1));
|
||||
@ -249,11 +249,11 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
|
||||
Collection<String> locations = new ArrayList<>();
|
||||
locations.add("wh0n94");
|
||||
locations.add("w");
|
||||
GeoHashUtils.addNeighbors("w", 1, locations);
|
||||
addNeighbors("w", 1, locations);
|
||||
locations.add("wh");
|
||||
GeoHashUtils.addNeighbors("wh", 2, locations);
|
||||
addNeighbors("wh", 2, locations);
|
||||
locations.add("wh0");
|
||||
GeoHashUtils.addNeighbors("wh0", 3, locations);
|
||||
addNeighbors("wh0", 3, locations);
|
||||
for (ContextMapping.QueryContext queryContext : queryContexts) {
|
||||
assertThat(queryContext.context, isIn(locations));
|
||||
assertThat(queryContext.boost, equalTo(10));
|
||||
@ -287,15 +287,15 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
|
||||
Collection<String> firstLocations = new ArrayList<>();
|
||||
firstLocations.add("wh0n94");
|
||||
firstLocations.add("w");
|
||||
GeoHashUtils.addNeighbors("w", 1, firstLocations);
|
||||
addNeighbors("w", 1, firstLocations);
|
||||
firstLocations.add("wh");
|
||||
GeoHashUtils.addNeighbors("wh", 2, firstLocations);
|
||||
addNeighbors("wh", 2, firstLocations);
|
||||
firstLocations.add("wh0");
|
||||
GeoHashUtils.addNeighbors("wh0", 3, firstLocations);
|
||||
addNeighbors("wh0", 3, firstLocations);
|
||||
Collection<String> secondLocations = new ArrayList<>();
|
||||
secondLocations.add("w5cx04");
|
||||
secondLocations.add("w5cx0");
|
||||
GeoHashUtils.addNeighbors("w5cx0", 5, secondLocations);
|
||||
addNeighbors("w5cx0", 5, secondLocations);
|
||||
for (ContextMapping.QueryContext queryContext : queryContexts) {
|
||||
if (firstLocations.contains(queryContext.context)) {
|
||||
assertThat(queryContext.boost, equalTo(10));
|
||||
@ -330,12 +330,12 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
|
||||
Collection<String> firstLocations = new ArrayList<>();
|
||||
firstLocations.add("wh0n94");
|
||||
firstLocations.add("w");
|
||||
GeoHashUtils.addNeighbors("w", 1, firstLocations);
|
||||
addNeighbors("w", 1, firstLocations);
|
||||
firstLocations.add("wh");
|
||||
GeoHashUtils.addNeighbors("wh", 2, firstLocations);
|
||||
addNeighbors("wh", 2, firstLocations);
|
||||
Collection<String> secondLocations = new ArrayList<>();
|
||||
secondLocations.add("w5cx04");
|
||||
GeoHashUtils.addNeighbors("w5cx04", 6, secondLocations);
|
||||
addNeighbors("w5cx04", 6, secondLocations);
|
||||
for (ContextMapping.QueryContext queryContext : queryContexts) {
|
||||
if (firstLocations.contains(queryContext.context)) {
|
||||
assertThat(queryContext.boost, equalTo(10));
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.test.geo;
|
||||
|
||||
import org.apache.lucene.util.GeoUtils;
|
||||
import org.apache.lucene.spatial.util.GeoUtils;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -1 +0,0 @@
|
||||
c1a6adaf97f1f341b311ddf050d2b19c79fb1945
|
@ -0,0 +1 @@
|
||||
94f03500c4b0256199b4dfcecf20be5b71c29177
|
@ -1 +0,0 @@
|
||||
52e20edd7a5fc828cd19bb49a603d57d7d4f2cd7
|
@ -0,0 +1 @@
|
||||
44365f83efda343500793c43a16903f2aa74ddbd
|
@ -1 +0,0 @@
|
||||
c28b1829a7510a59316761f0805072cf7441df24
|
@ -0,0 +1 @@
|
||||
7aca3e6bfe610df9cdc1b8fd671eac071016c228
|
@ -1 +0,0 @@
|
||||
c2e5d4357f2dad4aff99b9457ea916d259cb09f4
|
@ -0,0 +1 @@
|
||||
8c588d4d4c8fc6894dd6725dcf69ffa690c260f7
|
@ -1 +0,0 @@
|
||||
112959bececacfeaa72533ac94cca3d3d164550b
|
@ -0,0 +1 @@
|
||||
3ccad9ccffe94decc7c8c2a97fee3574c54b804c
|
@ -1 +0,0 @@
|
||||
975f42fac508bc999386955e449f5b91d123b569
|
@ -0,0 +1 @@
|
||||
b7eba4721b52f0490e71d8fdbc92112be538592b
|
@ -1 +0,0 @@
|
||||
3744a71c00220ef98dfcffc8265325709224fee5
|
@ -0,0 +1 @@
|
||||
6dde326efe42926c57dc49153536c689b9951203
|
@ -1 +0,0 @@
|
||||
e1fb855fc6711bc977587aecf42060d958f9f32b
|
@ -0,0 +1 @@
|
||||
3b8008f6b4195009960516fb1978912c0e068df2
|
@ -1 +0,0 @@
|
||||
74914a9410a5f8a43e72ff77532ae481c61f6384
|
@ -0,0 +1 @@
|
||||
00c681bca8129811901d2eff850e8b7855385448
|
@ -1 +0,0 @@
|
||||
f3a5c7242ecee80e80e5da0ff328897452cbec77
|
@ -0,0 +1 @@
|
||||
f8856c8286fde66ffa3d4745306f3849b4be808b
|
@ -1 +0,0 @@
|
||||
054bd6d6e3762af6828ae29805e2c6ccd136aaf8
|
@ -0,0 +1 @@
|
||||
dd5e43774a033b65c66c5e877104ffaf6a17c0b8
|
@ -1 +0,0 @@
|
||||
2580c4ccce1258580dbf8035e9e4ff1cf73b1cff
|
@ -0,0 +1 @@
|
||||
29fcb449512c0095e77ad2c96eca03b36e59745f
|
@ -1 +0,0 @@
|
||||
56ddb993dda8b6c0d68d64b1d4be6e088df29669
|
@ -0,0 +1 @@
|
||||
ea8d939136c58dbc388939ddc50bf9f6315528a4
|
@ -1 +0,0 @@
|
||||
bce01a0ba74c0df5caaf2b112537024371d03df4
|
@ -0,0 +1 @@
|
||||
b6dfab425bb5a0cbaf6adeb9ebec770cdce00046
|
@ -1 +0,0 @@
|
||||
477099ede788272484648ecd05d39d8745c74d6e
|
@ -0,0 +1 @@
|
||||
4017aff15660b508221e482c19ac6323b601229e
|
@ -40,7 +40,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.apache.lucene.util.GeoUtils.TOLERANCE;
|
||||
import static org.apache.lucene.spatial.util.GeoEncodingUtils.TOLERANCE;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
|
@ -1 +0,0 @@
|
||||
dc33b8449a6423132bf618bb1d32f464d191686d
|
@ -0,0 +1 @@
|
||||
c0d6b8f891a803dc0ce92da01e868a6ef31f0f09
|
@ -1 +0,0 @@
|
||||
d71ffab4f99835d863cd4b7b280469e62a98db61
|
@ -0,0 +1 @@
|
||||
8a8bcbbdc2d44ae64885e1e353b2cb66e1f906f5
|
@ -1 +0,0 @@
|
||||
30a9da299d3e4190833aebd07e814ce8fb9e9f78
|
@ -0,0 +1 @@
|
||||
9f176b3bdd40c6ccfcce53e9f4eae5273a71958f
|
@ -1 +0,0 @@
|
||||
a5f2374bc9180d842e823b681726ae2663ab1ebd
|
@ -0,0 +1 @@
|
||||
f2b1d0e000be8bfad3e3c88ba9d19f5b31edf69e
|
@ -1 +0,0 @@
|
||||
7d0ae501ad604447e02206f86e6592bcafd6a3f1
|
@ -0,0 +1 @@
|
||||
619040b891af8d2427a9f324148bb2e491685511
|
Loading…
x
Reference in New Issue
Block a user