This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new a8290de SOLR-13138: Remove deprecated spatial (#382)
a8290de is described below
commit a8290de0c1482a904012827ae2d7ae0e641e54a1
Author: David Smiley <[email protected]>
AuthorDate: Thu Nov 18 00:17:00 2021 -0500
SOLR-13138: Remove deprecated spatial (#382)
* Removed GeoHashField. (was deprecated)
* Removed LatLonType (was deprecated)
* Removed SpatialPointVectorFieldType (was deprecated)
* Removed SpatialTermQueryPrefixTreeFieldType (was deprecated)
* Removed spatial fields from some of our examples that don't exercise
spatial.
Other:
* Deprecate geohash() and ghhsin()
* Deprecated legacy/BBoxStrategy as we will switch to Lucene's.
Related to Trie/Points conversion.
* Reduced needless spatial in our test configs.
And made accommodations for the fact that the old LatLonType is gone;
mainly meaning LLPSF is the successor.
* Reduced needless spatial in our test configs.
---
.../java/org/apache/solr/legacy/BBoxStrategy.java | 1 +
.../org/apache/solr/legacy/BBoxValueSource.java | 1 +
.../apache/solr/legacy/DistanceValueSource.java | 120 ----
.../apache/solr/legacy/PointVectorStrategy.java | 289 ----------
.../java/org/apache/solr/schema/GeoHashField.java | 103 ----
.../java/org/apache/solr/schema/LatLonType.java | 606 ---------------------
.../src/java/org/apache/solr/schema/PointType.java | 4 +-
.../solr/schema/SpatialPointVectorFieldType.java | 106 ----
.../org/apache/solr/schema/SpatialQueryable.java | 2 +-
.../SpatialTermQueryPrefixTreeFieldType.java | 33 --
.../solr/search/SpatialFilterQParserPlugin.java | 8 +-
.../distance/GeoDistValueSourceParser.java | 2 +-
.../search/function/distance/GeohashFunction.java | 1 +
.../distance/GeohashHaversineFunction.java | 3 +-
.../solr/collection1/conf/schema-hash.xml | 28 -
.../solr/collection1/conf/schema-minhash.xml | 28 -
.../solr/collection1/conf/schema-rest.xml | 15 -
.../solr/collection1/conf/schema-spatial.xml | 23 +-
.../solr/collection1/conf/schema-sql.xml | 28 -
.../test-files/solr/collection1/conf/schema.xml | 21 +-
.../test-files/solr/collection1/conf/schema11.xml | 17 -
.../test-files/solr/collection1/conf/schema12.xml | 22 +-
.../test-files/solr/collection1/conf/schema15.xml | 18 +-
.../solr/collection1/conf/schema_latest.xml | 35 +-
.../solr/collection1/conf/schemasurround.xml | 17 -
.../solr/configsets/cloud-dynamic/conf/schema.xml | 14 +-
.../solr/configsets/doc-expiry/conf/schema.xml | 18 -
.../test-files/solr/configsets/sql/conf/schema.xml | 15 -
.../test/org/apache/solr/TestGroupingSearch.java | 14 +-
.../apache/solr/cloud/CollectionsAPISolrJTest.java | 2 -
.../solr/response/TestGeoJSONResponseWriter.java | 9 +-
.../rest/schema/TestFieldCollectionResource.java | 24 +-
.../org/apache/solr/search/QueryEqualityTest.java | 40 +-
.../org/apache/solr/search/ReturnFieldsTest.java | 22 +-
.../org/apache/solr/search/SpatialFilterTest.java | 21 +-
.../org/apache/solr/search/TestSolr4Spatial.java | 5 +-
.../apache/solr/search/TestValueSourceCache.java | 6 +-
.../function/distance/DistanceFunctionTest.java | 80 ++-
.../AbstractAtomicUpdatesMultivalueTestBase.java | 6 +-
.../src/field-types-included-with-solr.adoc | 2 -
.../src/partial-document-updates.adoc | 2 +-
solr/solr-ref-guide/src/spatial-search.adoc | 16 +-
.../solrj/solr/collection1/conf/schema-sql.xml | 28 -
.../solrj/solr/collection1/conf/schema.xml | 28 -
.../solr/configsets/streaming/conf/schema.xml | 31 +-
45 files changed, 163 insertions(+), 1751 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/legacy/BBoxStrategy.java
b/solr/core/src/java/org/apache/solr/legacy/BBoxStrategy.java
index ed00d5e..1e464b0 100644
--- a/solr/core/src/java/org/apache/solr/legacy/BBoxStrategy.java
+++ b/solr/core/src/java/org/apache/solr/legacy/BBoxStrategy.java
@@ -75,6 +75,7 @@ import org.locationtech.spatial4j.shape.Shape;
*
* @lucene.experimental
*/
+@Deprecated
public class BBoxStrategy extends SpatialStrategy {
// note: we use a FieldType to articulate the options we want on the field.
We don't use it as-is with a Field, we
diff --git a/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
b/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
index 516f207..10f5713 100644
--- a/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
+++ b/solr/core/src/java/org/apache/solr/legacy/BBoxValueSource.java
@@ -33,6 +33,7 @@ import org.locationtech.spatial4j.shape.Shape;
*
* @lucene.internal
*/
+@Deprecated
class BBoxValueSource extends ShapeValuesSource {
private final BBoxStrategy strategy;
diff --git a/solr/core/src/java/org/apache/solr/legacy/DistanceValueSource.java
b/solr/core/src/java/org/apache/solr/legacy/DistanceValueSource.java
deleted file mode 100644
index 33faf9f..0000000
--- a/solr/core/src/java/org/apache/solr/legacy/DistanceValueSource.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.legacy;
-
-import java.io.IOException;
-
-import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.search.DoubleValues;
-import org.apache.lucene.search.DoubleValuesSource;
-import org.apache.lucene.search.IndexSearcher;
-import org.locationtech.spatial4j.distance.DistanceCalculator;
-import org.locationtech.spatial4j.shape.Point;
-
-/**
- * An implementation of the Lucene ValueSource model that returns the distance
- * for a {@link PointVectorStrategy}.
- *
- * @lucene.internal
- */
-public class DistanceValueSource extends DoubleValuesSource {
-
- private PointVectorStrategy strategy;
- private final Point from;
- private final double multiplier;
- private final double nullValue;
-
-
- /**
- * Constructor.
- */
- public DistanceValueSource(PointVectorStrategy strategy, Point from, double
multiplier) {
- this.strategy = strategy;
- this.from = from;
- this.multiplier = multiplier;
- this.nullValue =
- (strategy.getSpatialContext().isGeo() ? 180 * multiplier :
Double.MAX_VALUE);
- }
-
- /**
- * Returns the ValueSource description.
- */
- @Override
- public String toString() {
- return "DistanceValueSource("+strategy+", "+from+")";
- }
-
- /**
- * Returns the FunctionValues used by the function query.
- */
- @Override
- public DoubleValues getValues(LeafReaderContext readerContext, DoubleValues
scores) throws IOException {
-
- final DoubleValues ptX =
DoubleValuesSource.fromDoubleField(strategy.getFieldNameX()).getValues(readerContext,
null);
- final DoubleValues ptY =
DoubleValuesSource.fromDoubleField(strategy.getFieldNameY()).getValues(readerContext,
null);
- final DistanceCalculator calculator =
strategy.getSpatialContext().getDistCalc();
-
- return DoubleValues.withDefault(new DoubleValues() {
-
- @Override
- public double doubleValue() throws IOException {
- return calculator.distance(from, ptX.doubleValue(), ptY.doubleValue())
* multiplier;
- }
-
- @Override
- public boolean advanceExact(int doc) throws IOException {
- return ptX.advanceExact(doc) && ptY.advanceExact(doc);
- }
- }, nullValue);
-
- }
-
- @Override
- public boolean needsScores() {
- return false;
- }
-
- @Override
- public boolean isCacheable(LeafReaderContext ctx) {
- return DocValues.isCacheable(ctx, strategy.getFieldNameX(),
strategy.getFieldNameY());
- }
-
- @Override
- public DoubleValuesSource rewrite(IndexSearcher searcher) throws IOException
{
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- DistanceValueSource that = (DistanceValueSource) o;
-
- if (!from.equals(that.from)) return false;
- if (!strategy.equals(that.strategy)) return false;
- if (multiplier != that.multiplier) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return from.hashCode();
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/legacy/PointVectorStrategy.java
b/solr/core/src/java/org/apache/solr/legacy/PointVectorStrategy.java
deleted file mode 100644
index da48fcb..0000000
--- a/solr/core/src/java/org/apache/solr/legacy/PointVectorStrategy.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.legacy;
-
-import org.apache.lucene.document.DoubleDocValuesField;
-import org.apache.lucene.document.DoublePoint;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.index.DocValuesType;
-import org.apache.lucene.index.IndexOptions;
-import org.apache.lucene.queries.function.FunctionMatchQuery;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.ConstantScoreQuery;
-import org.apache.lucene.search.DoubleValuesSource;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.spatial.SpatialStrategy;
-import org.apache.lucene.spatial.query.SpatialArgs;
-import org.apache.lucene.spatial.query.SpatialOperation;
-import org.apache.lucene.spatial.query.UnsupportedSpatialOperation;
-import org.locationtech.spatial4j.context.SpatialContext;
-import org.locationtech.spatial4j.shape.Circle;
-import org.locationtech.spatial4j.shape.Point;
-import org.locationtech.spatial4j.shape.Rectangle;
-import org.locationtech.spatial4j.shape.Shape;
-
-/**
- * Simple {@link SpatialStrategy} which represents Points in two numeric
fields.
- * The Strategy's best feature is decent distance sort.
- *
- * <p>
- * <b>Characteristics:</b>
- * <br>
- * <ul>
- * <li>Only indexes points; just one per field value.</li>
- * <li>Can query by a rectangle or circle.</li>
- * <li>{@link
- * org.apache.lucene.spatial.query.SpatialOperation#Intersects} and {@link
- * SpatialOperation#IsWithin} is supported.</li>
- * <li>Requires DocValues for
- * {@link #makeDistanceValueSource(org.locationtech.spatial4j.shape.Point)}
and for
- * searching with a Circle.</li>
- * </ul>
- *
- * <p>
- * <b>Implementation:</b>
- * <p>
- * This is a simple Strategy. Search works with a pair of range queries on
two {@link DoublePoint}s representing
- * x & y fields. A Circle query does the same bbox query but adds a
- * ValueSource filter on
- * {@link #makeDistanceValueSource(org.locationtech.spatial4j.shape.Point)}.
- * <p>
- * One performance shortcoming with this strategy is that a scenario involving
- * both a search using a Circle and sort will result in calculations for the
- * spatial distance being done twice -- once for the filter and second for the
- * sort.
- *
- * @lucene.experimental
- */
-public class PointVectorStrategy extends SpatialStrategy {
-
- // note: we use a FieldType to articulate the options we want on the field.
We don't use it as-is with a Field, we
- // create more than one Field.
-
- /**
- * pointValues, docValues, and nothing else.
- */
- public static FieldType DEFAULT_FIELDTYPE;
-
- @Deprecated
- public static LegacyFieldType LEGACY_FIELDTYPE;
- static {
- // Default: pointValues + docValues
- FieldType type = new FieldType();
- type.setDimensions(1, Double.BYTES);//pointValues (assume Double)
- type.setDocValuesType(DocValuesType.NUMERIC);//docValues
- type.setStored(false);
- type.freeze();
- DEFAULT_FIELDTYPE = type;
- // Legacy default: legacyNumerics
- LegacyFieldType legacyType = new LegacyFieldType();
- legacyType.setIndexOptions(IndexOptions.DOCS);
- legacyType.setNumericType(LegacyNumericType.DOUBLE);
- legacyType.setNumericPrecisionStep(8);// same as solr default
- legacyType.setDocValuesType(DocValuesType.NONE);//no docValues!
- legacyType.setStored(false);
- legacyType.freeze();
- LEGACY_FIELDTYPE = legacyType;
- }
-
- public static final String SUFFIX_X = "__x";
- public static final String SUFFIX_Y = "__y";
-
- private final String fieldNameX;
- private final String fieldNameY;
-
- private final int fieldsLen;
- private final boolean hasStored;
- private final boolean hasDocVals;
- private final boolean hasPointVals;
- // equiv to "hasLegacyNumerics":
- private final LegacyFieldType legacyNumericFieldType; // not stored; holds
precision step.
-
- /**
- * Create a new {@link PointVectorStrategy} instance that uses {@link
DoublePoint} and {@link DoublePoint#newRangeQuery}
- */
- public static PointVectorStrategy newInstance(SpatialContext ctx, String
fieldNamePrefix) {
- return new PointVectorStrategy(ctx, fieldNamePrefix, DEFAULT_FIELDTYPE);
- }
-
- /**
- * Create a new {@link PointVectorStrategy} instance that uses {@link
LegacyDoubleField} for backwards compatibility.
- * However, back-compat is limited; we don't support circle queries or
{@link #makeDistanceValueSource(Point, double)}
- * since that requires docValues (the legacy config didn't have that).
- *
- * @deprecated LegacyNumerics will be removed
- */
- @Deprecated
- public static PointVectorStrategy newLegacyInstance(SpatialContext ctx,
String fieldNamePrefix) {
- return new PointVectorStrategy(ctx, fieldNamePrefix, LEGACY_FIELDTYPE);
- }
-
- /**
- * Create a new instance configured with the provided FieldType options. See
{@link #DEFAULT_FIELDTYPE}.
- * a field type is used to articulate the desired options (namely
pointValues, docValues, stored). Legacy numerics
- * is configurable this way too.
- */
- public PointVectorStrategy(SpatialContext ctx, String fieldNamePrefix,
FieldType fieldType) {
- super(ctx, fieldNamePrefix);
- this.fieldNameX = fieldNamePrefix+SUFFIX_X;
- this.fieldNameY = fieldNamePrefix+SUFFIX_Y;
-
- int numPairs = 0;
- if ((this.hasStored = fieldType.stored())) {
- numPairs++;
- }
- if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {
- numPairs++;
- }
- if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
- numPairs++;
- }
- if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof
LegacyFieldType && ((LegacyFieldType)fieldType).numericType() != null) {
- if (hasPointVals) {
- throw new IllegalArgumentException("pointValues and LegacyNumericType
are mutually exclusive");
- }
- final LegacyFieldType legacyType = (LegacyFieldType) fieldType;
- if (legacyType.numericType() != LegacyNumericType.DOUBLE) {
- throw new IllegalArgumentException(getClass() + " does not support " +
legacyType.numericType());
- }
- numPairs++;
- legacyNumericFieldType = new
LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED);
-
legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep());
- legacyNumericFieldType.freeze();
- } else {
- legacyNumericFieldType = null;
- }
- this.fieldsLen = numPairs * 2;
- }
-
-
- String getFieldNameX() {
- return fieldNameX;
- }
-
- String getFieldNameY() {
- return fieldNameY;
- }
-
- @Override
- public Field[] createIndexableFields(Shape shape) {
- if (shape instanceof Point)
- return createIndexableFields((Point) shape);
- throw new UnsupportedOperationException("Can only index Point, not " +
shape);
- }
-
- /** @see #createIndexableFields(org.locationtech.spatial4j.shape.Shape) */
- public Field[] createIndexableFields(Point point) {
- Field[] fields = new Field[fieldsLen];
- int idx = -1;
- if (hasStored) {
- fields[++idx] = new StoredField(fieldNameX, point.getX());
- fields[++idx] = new StoredField(fieldNameY, point.getY());
- }
- if (hasDocVals) {
- fields[++idx] = new DoubleDocValuesField(fieldNameX, point.getX());
- fields[++idx] = new DoubleDocValuesField(fieldNameY, point.getY());
- }
- if (hasPointVals) {
- fields[++idx] = new DoublePoint(fieldNameX, point.getX());
- fields[++idx] = new DoublePoint(fieldNameY, point.getY());
- }
- if (legacyNumericFieldType != null) {
- fields[++idx] = new LegacyDoubleField(fieldNameX, point.getX(),
legacyNumericFieldType);
- fields[++idx] = new LegacyDoubleField(fieldNameY, point.getY(),
legacyNumericFieldType);
- }
- assert idx == fields.length - 1;
- return fields;
- }
-
- @Override
- public DoubleValuesSource makeDistanceValueSource(Point queryPoint, double
multiplier) {
- return new DistanceValueSource(this, queryPoint, multiplier);
- }
-
- @Override
- public ConstantScoreQuery makeQuery(SpatialArgs args) {
- if(! SpatialOperation.is( args.getOperation(),
- SpatialOperation.Intersects,
- SpatialOperation.IsWithin ))
- throw new UnsupportedSpatialOperation(args.getOperation());
- Shape shape = args.getShape();
- if (shape instanceof Rectangle) {
- Rectangle bbox = (Rectangle) shape;
- return new ConstantScoreQuery(makeWithin(bbox));
- } else if (shape instanceof Circle) {
- Circle circle = (Circle)shape;
- Rectangle bbox = circle.getBoundingBox();
- Query approxQuery = makeWithin(bbox);
- BooleanQuery.Builder bqBuilder = new BooleanQuery.Builder();
- double r = circle.getRadius();
- FunctionMatchQuery vsMatchQuery = new
FunctionMatchQuery(makeDistanceValueSource(circle.getCenter()),
- v -> 0 <= v && v <= r);
- bqBuilder.add(approxQuery, BooleanClause.Occur.FILTER);//should have
lowest "cost" value; will drive iteration
- bqBuilder.add(vsMatchQuery, BooleanClause.Occur.FILTER);
- return new ConstantScoreQuery(bqBuilder.build());
- } else {
- throw new UnsupportedOperationException("Only Rectangles and Circles are
currently supported, " +
- "found [" + shape.getClass() + "]");//TODO
- }
- }
-
- /**
- * Constructs a query to retrieve documents that fully contain the input
envelope.
- */
- private Query makeWithin(Rectangle bbox) {
- BooleanQuery.Builder bq = new BooleanQuery.Builder();
- BooleanClause.Occur MUST = BooleanClause.Occur.MUST;
- if (bbox.getCrossesDateLine()) {
- //use null as performance trick since no data will be beyond the world
bounds
- bq.add(rangeQuery(fieldNameX, null/*-180*/, bbox.getMaxX()),
BooleanClause.Occur.SHOULD );
- bq.add(rangeQuery(fieldNameX, bbox.getMinX(), null/*+180*/),
BooleanClause.Occur.SHOULD );
- bq.setMinimumNumberShouldMatch(1);//must match at least one of the SHOULD
- } else {
- bq.add(rangeQuery(fieldNameX, bbox.getMinX(), bbox.getMaxX()), MUST);
- }
- bq.add(rangeQuery(fieldNameY, bbox.getMinY(), bbox.getMaxY()), MUST);
- return bq.build();
- }
-
- /**
- * Returns a numeric range query based on FieldType
- * {@link LegacyNumericRangeQuery} is used for indexes created using {@code
FieldType.LegacyNumericType}
- * {@link DoublePoint#newRangeQuery} is used for indexes created using
{@link DoublePoint} fields
- */
- private Query rangeQuery(String fieldName, Double min, Double max) {
- if (hasPointVals) {
- if (min == null) {
- min = Double.NEGATIVE_INFINITY;
- }
-
- if (max == null) {
- max = Double.POSITIVE_INFINITY;
- }
-
- return DoublePoint.newRangeQuery(fieldName, min, max);
-
- } else if (legacyNumericFieldType != null) {// todo remove legacy numeric
support in 7.0
- return LegacyNumericRangeQuery.newDoubleRange(fieldName,
legacyNumericFieldType.numericPrecisionStep(), min, max, true, true);//inclusive
- }
- //TODO try doc-value range query?
- throw new UnsupportedOperationException("An index is required for this
operation.");
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/schema/GeoHashField.java
b/solr/core/src/java/org/apache/solr/schema/GeoHashField.java
deleted file mode 100644
index 842333f..0000000
--- a/solr/core/src/java/org/apache/solr/schema/GeoHashField.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.schema;
-
-import java.io.IOException;
-
-import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.valuesource.LiteralValueSource;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.SortField;
-import org.apache.solr.response.TextResponseWriter;
-import org.apache.solr.search.QParser;
-import org.apache.solr.search.SolrConstantScoreQuery;
-import org.apache.solr.search.SpatialOptions;
-import org.apache.solr.search.function.ValueSourceRangeFilter;
-import org.apache.solr.search.function.distance.GeohashHaversineFunction;
-import org.apache.solr.uninverting.UninvertingReader.Type;
-import org.apache.solr.util.SpatialUtils;
-import org.locationtech.spatial4j.context.SpatialContext;
-import org.locationtech.spatial4j.distance.DistanceUtils;
-import org.locationtech.spatial4j.io.GeohashUtils;
-import org.locationtech.spatial4j.shape.Point;
-
-/**
- * This is a class that represents a <a
- * href="http://en.wikipedia.org/wiki/Geohash">Geohash</a> field. The field is
- * provided as a lat/lon pair and is internally represented as a string.
- *
- * @deprecated use {@link LatLonPointSpatialField} instead
- */
-@Deprecated
-public class GeoHashField extends FieldType implements SpatialQueryable {
-
- @Override
- public SortField getSortField(SchemaField field, boolean top) {
- return getStringSort(field, top);
- }
-
- @Override
- public Type getUninversionType(SchemaField sf) {
- if (sf.multiValued()) {
- return Type.SORTED_SET_BINARY;
- } else {
- return Type.SORTED;
- }
- }
-
- //QUESTION: Should we do a fast and crude one? Or actually check distances
- //Fast and crude could use EdgeNGrams, but that would require a different
- //encoding. Plus there are issues around the Equator/Prime Meridian
- @Override
- public Query createSpatialQuery(QParser parser, SpatialOptions options) {
- String geohash = toInternal(options.pointStr);
- //TODO: optimize this
- return new SolrConstantScoreQuery(new ValueSourceRangeFilter(new
GeohashHaversineFunction(getValueSource(options.field, parser),
- new LiteralValueSource(geohash), options.radius), "0",
String.valueOf(options.distance), true, true));
- }
-
- @Override
- public void write(TextResponseWriter writer, String name, IndexableField f)
- throws IOException {
- writer.writeStr(name, toExternal(f), false);
- }
-
- @Override
- public String toExternal(IndexableField f) {
- Point p = GeohashUtils.decode(f.stringValue(), SpatialContext.GEO);
- return p.getY() + "," + p.getX();
- }
-
- @Override
- public String toInternal(String val) {
- Point point = SpatialUtils.parsePointSolrException(val,
SpatialContext.GEO);
- return GeohashUtils.encodeLatLon(point.getY(), point.getX());
- }
-
- @Override
- public ValueSource getValueSource(SchemaField field, QParser parser) {
- field.checkFieldCacheSource();
- return new StrFieldSource(field.name);
- }
-
- @Override
- public double getSphereRadius() {
- return DistanceUtils.EARTH_MEAN_RADIUS_KM;
- }
-
-}
diff --git a/solr/core/src/java/org/apache/solr/schema/LatLonType.java
b/solr/core/src/java/org/apache/solr/schema/LatLonType.java
deleted file mode 100644
index 213d494..0000000
--- a/solr/core/src/java/org/apache/solr/schema/LatLonType.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.schema;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.valuesource.VectorValueSource;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.ConstantScoreWeight;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryVisitor;
-import org.apache.lucene.search.ScoreMode;
-import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.SortField;
-import org.apache.lucene.search.Weight;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.response.TextResponseWriter;
-import org.apache.solr.search.DelegatingCollector;
-import org.apache.solr.search.ExtendedQueryBase;
-import org.apache.solr.search.PostFilter;
-import org.apache.solr.search.QParser;
-import org.apache.solr.search.SpatialOptions;
-import org.apache.solr.uninverting.UninvertingReader.Type;
-import org.apache.solr.util.SpatialUtils;
-import org.locationtech.spatial4j.context.SpatialContext;
-import org.locationtech.spatial4j.distance.DistanceUtils;
-import org.locationtech.spatial4j.shape.Point;
-import org.locationtech.spatial4j.shape.Rectangle;
-
-
-/**
- * Represents a Latitude/Longitude as a 2 dimensional point. Latitude is
<b>always</b> specified first.
- *
- * @deprecated use {@link LatLonPointSpatialField} instead
- */
-@Deprecated
-public class LatLonType extends AbstractSubTypeFieldType implements
SpatialQueryable {
- protected static final int LAT = 0;
- protected static final int LON = 1;
-
- @Override
- protected void init(IndexSchema schema, Map<String, String> args) {
- super.init(schema, args);
- //TODO: refactor this, as we are creating the suffix cache twice, since
the super.init does it too
- createSuffixCache(3);//we need three extra fields: one for the storage
field, two for the lat/lon
- }
-
- @Override
- public List<IndexableField> createFields(SchemaField field, Object value) {
- String externalVal = value.toString();
- //we could have 3 fields (two for the lat & lon, one for storage)
- List<IndexableField> f = new ArrayList<>(3);
- if (field.indexed()) {
- Point point = SpatialUtils.parsePointSolrException(externalVal,
SpatialContext.GEO);
- //latitude
- SchemaField subLatSF = subField(field, LAT, schema);
- f.addAll(subLatSF.createFields(String.valueOf(point.getY())));
- //longitude
- SchemaField subLonSF = subField(field, LON, schema);
- f.addAll(subLonSF.createFields(String.valueOf(point.getX())));
- }
-
- if (field.stored()) {
- f.add(createField(field.getName(), externalVal, StoredField.TYPE));
- }
- return f;
- }
-
- @Override
- protected void checkSupportsDocValues() {
- // DocValues supported only when enabled at the fieldType
- if (!hasProperty(DOC_VALUES)) {
- throw new UnsupportedOperationException("LatLonType can't have
docValues=true in the field definition, use docValues=true in the fieldType
definition, or in subFieldType/subFieldSuffix");
- }
- }
-
-
- @Override
- protected Query getSpecializedRangeQuery(QParser parser, SchemaField field,
String part1, String part2, boolean minInclusive, boolean maxInclusive) {
- Point p1 = SpatialUtils.parsePointSolrException(part1, SpatialContext.GEO);
- Point p2 = SpatialUtils.parsePointSolrException(part2, SpatialContext.GEO);
-
- SchemaField latSF = subField(field, LAT, parser.getReq().getSchema());
- SchemaField lonSF = subField(field, LON, parser.getReq().getSchema());
- BooleanQuery.Builder result = new BooleanQuery.Builder();
- // points must currently be ordered... should we support specifying any
two opposite corner points?
- result.add(latSF.getType().getRangeQuery(parser, latSF,
- Double.toString(p1.getY()), Double.toString(p2.getY()), minInclusive,
maxInclusive), BooleanClause.Occur.MUST);
- result.add(lonSF.getType().getRangeQuery(parser, lonSF,
- Double.toString(p1.getX()), Double.toString(p2.getX()), minInclusive,
maxInclusive), BooleanClause.Occur.MUST);
- return result.build();
- }
-
- @Override
- public Query getFieldQuery(QParser parser, SchemaField field, String
externalVal) {
- Point p1 = SpatialUtils.parsePointSolrException(externalVal,
SpatialContext.GEO);
-
- SchemaField latSF = subField(field, LAT, parser.getReq().getSchema());
- SchemaField lonSF = subField(field, LON, parser.getReq().getSchema());
- BooleanQuery.Builder result = new BooleanQuery.Builder();
- result.add(latSF.getType().getFieldQuery(parser, latSF,
- Double.toString(p1.getY())), BooleanClause.Occur.MUST);
- result.add(lonSF.getType().getFieldQuery(parser, lonSF,
- Double.toString(p1.getX())), BooleanClause.Occur.MUST);
- return result.build();
- }
-
-
-
- @Override
- public Query createSpatialQuery(QParser parser, SpatialOptions options) {
- Point point = SpatialUtils.parsePointSolrException(options.pointStr,
SpatialContext.GEO);
-
- // lat & lon in degrees
- double latCenter = point.getY();
- double lonCenter = point.getX();
-
- double distDeg = DistanceUtils.dist2Degrees(options.distance,
options.radius);
- Rectangle bbox = DistanceUtils.calcBoxByDistFromPtDEG(latCenter,
lonCenter, distDeg, SpatialContext.GEO, null);
- double latMin = bbox.getMinY();
- double latMax = bbox.getMaxY();
- double lonMin, lonMax, lon2Min, lon2Max;
- if (bbox.getCrossesDateLine()) {
- lonMin = -180;
- lonMax = bbox.getMaxX();
- lon2Min = bbox.getMinX();
- lon2Max = 180;
- } else {
- lonMin = bbox.getMinX();
- lonMax = bbox.getMaxX();
- lon2Min = -180;
- lon2Max = 180;
- }
-
- IndexSchema schema = parser.getReq().getSchema();
-
- // Now that we've figured out the ranges, build them!
- SchemaField latSF = subField(options.field, LAT, schema);
- SchemaField lonSF = subField(options.field, LON, schema);
-
- SpatialDistanceQuery spatial = new SpatialDistanceQuery();
-
-
- if (options.bbox) {
- BooleanQuery.Builder result = new BooleanQuery.Builder();
-
- Query latRange = latSF.getType().getRangeQuery(parser, latSF,
- String.valueOf(latMin),
- String.valueOf(latMax),
- true, true);
- result.add(latRange, BooleanClause.Occur.MUST);
-
- if (lonMin != -180 || lonMax != 180) {
- Query lonRange = lonSF.getType().getRangeQuery(parser, lonSF,
- String.valueOf(lonMin),
- String.valueOf(lonMax),
- true, true);
- if (lon2Min != -180 || lon2Max != 180) {
- // another valid longitude range
- BooleanQuery.Builder bothLons = new BooleanQuery.Builder();
- bothLons.add(lonRange, BooleanClause.Occur.SHOULD);
-
- lonRange = lonSF.getType().getRangeQuery(parser, lonSF,
- String.valueOf(lon2Min),
- String.valueOf(lon2Max),
- true, true);
- bothLons.add(lonRange, BooleanClause.Occur.SHOULD);
-
- lonRange = bothLons.build();
- }
-
- result.add(lonRange, BooleanClause.Occur.MUST);
- }
-
- spatial.bboxQuery = result.build();
- }
-
-
- spatial.origField = options.field.getName();
- spatial.latSource = latSF.getType().getValueSource(latSF, parser);
- spatial.lonSource = lonSF.getType().getValueSource(lonSF, parser);
- spatial.latMin = latMin;
- spatial.latMax = latMax;
- spatial.lonMin = lonMin;
- spatial.lonMax = lonMax;
- spatial.lon2Min = lon2Min;
- spatial.lon2Max = lon2Max;
- spatial.lon2 = lon2Min != -180 || lon2Max != 180;
-
- spatial.latCenter = latCenter;
- spatial.lonCenter = lonCenter;
- spatial.dist = options.distance;
- spatial.planetRadius = options.radius;
-
- spatial.calcDist = !options.bbox;
-
- return spatial;
- }
-
- @Override
- public ValueSource getValueSource(SchemaField field, QParser parser) {
- ArrayList<ValueSource> vs = new ArrayList<>(2);
- for (int i = 0; i < 2; i++) {
- SchemaField sub = subField(field, i, schema);
- vs.add(sub.getType().getValueSource(sub, parser));
- }
- return new LatLonValueSource(field, vs);
- }
-
- @Override
- public boolean isPolyField() {
- return true;
- }
-
- @Override
- public void write(TextResponseWriter writer, String name, IndexableField f)
throws IOException {
- writer.writeStr(name, f.stringValue(), true);
- }
-
- @Override
- public SortField getSortField(SchemaField field, boolean top) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Sorting not
supported on LatLonType " + field.getName());
- }
-
- @Override
- public Type getUninversionType(SchemaField sf) {
- return null;
- }
-
-
-
- //It never makes sense to create a single field, so make it impossible to
happen
-
- @Override
- public IndexableField createField(SchemaField field, Object value) {
- throw new UnsupportedOperationException("LatLonType uses multiple fields.
field=" + field.getName());
- }
-
- @Override
- public double getSphereRadius() {
- return DistanceUtils.EARTH_MEAN_RADIUS_KM;
- }
-
-}
-
-class LatLonValueSource extends VectorValueSource {
- private final SchemaField sf;
-
- public LatLonValueSource(SchemaField sf, List<ValueSource> sources) {
- super(sources);
- this.sf = sf;
- }
-
- @Override
- public String name() {
- return "latlon";
- }
-
- @Override
- public String description() {
- return name() + "(" + sf.getName() + ")";
- }
-}
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////
-// TODO: recast as a value source that doesn't have to match all docs
-
-class SpatialDistanceQuery extends ExtendedQueryBase implements PostFilter {
- String origField;
- ValueSource latSource;
- ValueSource lonSource;
- double lonMin, lonMax, lon2Min, lon2Max, latMin, latMax;
- boolean lon2;
-
- boolean calcDist; // actually calculate the distance with haversine
- Query bboxQuery;
-
- double latCenter;
- double lonCenter;
- double dist;
- double planetRadius;
-
-
- @Override
- public Query rewrite(IndexReader reader) throws IOException {
- return bboxQuery != null ? bboxQuery.rewrite(reader) : this;
- }
-
- protected class SpatialWeight extends ConstantScoreWeight {
- protected IndexSearcher searcher;
- protected Map<Object,Object> latContext;
- protected Map<Object,Object> lonContext;
-
- public SpatialWeight(IndexSearcher searcher, float boost) throws
IOException {
- super(SpatialDistanceQuery.this, boost);
- this.searcher = searcher;
- this.latContext = ValueSource.newContext(searcher);
- this.lonContext = ValueSource.newContext(searcher);
- latSource.createWeight(latContext, searcher);
- lonSource.createWeight(lonContext, searcher);
- }
-
- @Override
- public Scorer scorer(LeafReaderContext context) throws IOException {
- return new SpatialScorer(context, this, score());
- }
-
- @Override
- public boolean isCacheable(LeafReaderContext ctx) {
- return false;
- }
-
- @Override
- public Explanation explain(LeafReaderContext context, int doc) throws
IOException {
- return ((SpatialScorer)scorer(context)).explain(super.explain(context,
doc), doc);
- }
- }
-
- protected class SpatialScorer extends Scorer {
- final IndexReader reader;
- final SpatialWeight weight;
- final int maxDoc;
- final float qWeight;
- int doc=-1;
- final FunctionValues latVals;
- final FunctionValues lonVals;
-
-
- final double lonMin, lonMax, lon2Min, lon2Max, latMin, latMax;
- final boolean lon2;
- final boolean calcDist;
-
- final double latCenterRad;
- final double lonCenterRad;
- final double latCenterRad_cos;
- final double dist;
- final double planetRadius;
-
- int lastDistDoc;
- double lastDist;
-
- @SuppressWarnings({"unchecked"})
- public SpatialScorer(LeafReaderContext readerContext, SpatialWeight w,
float qWeight) throws IOException {
- super(w);
- this.weight = w;
- this.qWeight = qWeight;
- this.reader = readerContext.reader();
- this.maxDoc = reader.maxDoc();
- latVals = latSource.getValues(weight.latContext, readerContext);
- lonVals = lonSource.getValues(weight.lonContext, readerContext);
-
- this.lonMin = SpatialDistanceQuery.this.lonMin;
- this.lonMax = SpatialDistanceQuery.this.lonMax;
- this.lon2Min = SpatialDistanceQuery.this.lon2Min;
- this.lon2Max = SpatialDistanceQuery.this.lon2Max;
- this.latMin = SpatialDistanceQuery.this.latMin;
- this.latMax = SpatialDistanceQuery.this.latMax;
- this.lon2 = SpatialDistanceQuery.this.lon2;
- this.calcDist = SpatialDistanceQuery.this.calcDist;
-
- this.latCenterRad = SpatialDistanceQuery.this.latCenter *
DistanceUtils.DEGREES_TO_RADIANS;
- this.lonCenterRad = SpatialDistanceQuery.this.lonCenter *
DistanceUtils.DEGREES_TO_RADIANS;
- this.latCenterRad_cos = this.calcDist ? Math.cos(latCenterRad) : 0;
- this.dist = SpatialDistanceQuery.this.dist;
- this.planetRadius = SpatialDistanceQuery.this.planetRadius;
-
- }
-
- boolean match() throws IOException {
- // longitude should generally be more restrictive than latitude
- // (e.g. in the US, it immediately separates the coasts, and in world
search separates
- // US from Europe from Asia, etc.
- double lon = lonVals.doubleVal(doc);
- if (! ((lon >= lonMin && lon <=lonMax) || (lon2 && lon >= lon2Min && lon
<= lon2Max)) ) {
- return false;
- }
-
- double lat = latVals.doubleVal(doc);
- if ( !(lat >= latMin && lat <= latMax) ) {
- return false;
- }
-
- if (!calcDist) return true;
-
- // TODO: test for internal box where we wouldn't need to calculate the
distance
-
- return dist(lat, lon) <= dist;
- }
-
- double dist(double lat, double lon) {
- double latRad = lat * DistanceUtils.DEGREES_TO_RADIANS;
- double lonRad = lon * DistanceUtils.DEGREES_TO_RADIANS;
-
- // haversine, specialized to avoid a cos() call on latCenterRad
- double diffX = latCenterRad - latRad;
- double diffY = lonCenterRad - lonRad;
- double hsinX = Math.sin(diffX * 0.5);
- double hsinY = Math.sin(diffY * 0.5);
- double h = hsinX * hsinX +
- (latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);
- double result = (planetRadius * 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1
- h)));
-
- // save the results of this calculation
- lastDistDoc = doc;
- lastDist = result;
-
- return result;
- }
-
- @Override
- public int docID() {
- return doc;
- }
-
- @Override
- public DocIdSetIterator iterator() {
- return new DocIdSetIterator() {
-
- @Override
- public int docID() {
- return doc;
- }
-
- // instead of matching all docs, we could also embed a query.
- // the score could either ignore the subscore, or boost it.
- // Containment: floatline(foo:myTerm, "myFloatField", 1.0, 0.0f)
- // Boost: foo:myTerm^floatline("myFloatField",1.0,0.0f)
- @Override
- public int nextDoc() throws IOException {
- for(;;) {
- ++doc;
- if (doc>=maxDoc) {
- return doc=NO_MORE_DOCS;
- }
- if (!match()) continue;
- return doc;
- }
- }
-
- @Override
- public int advance(int target) throws IOException {
- // this will work even if target==NO_MORE_DOCS
- doc=target-1;
- return nextDoc();
- }
-
- @Override
- public long cost() {
- return maxDoc;
- }
-
- };
- }
-
- @Override
- public float score() throws IOException {
- double dist = (doc == lastDistDoc) ? lastDist :
dist(latVals.doubleVal(doc), lonVals.doubleVal(doc));
- return (float)(dist * qWeight);
- }
-
- @Override
- public float getMaxScore(int upTo) throws IOException {
- return Float.POSITIVE_INFINITY;
- }
-
- public Explanation explain(Explanation base, int doc) throws IOException {
- if (base.isMatch() == false) {
- return base;
- }
- double dist = dist(latVals.doubleVal(doc), lonVals.doubleVal(doc));
-
- String description = SpatialDistanceQuery.this.toString();
- return Explanation.match((float) (base.getValue().floatValue() * dist),
description + " product of:",
- base, Explanation.match((float) dist,
"hsin("+latVals.doubleVal(doc)+","+lonVals.doubleVal(doc)));
- }
-
- }
-
- @Override
- public DelegatingCollector getFilterCollector(IndexSearcher searcher) {
- try {
- return new SpatialCollector(new SpatialWeight(searcher, 1f));
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
- }
- }
-
-
- class SpatialCollector extends DelegatingCollector {
- final SpatialWeight weight;
- SpatialScorer spatialScorer;
- int maxdoc;
-
- public SpatialCollector(SpatialWeight weight) {
- this.weight = weight;
- }
-
- @Override
- public void collect(int doc) throws IOException {
- spatialScorer.doc = doc;
- if (spatialScorer.match()) leafDelegate.collect(doc);
- }
-
- @Override
- protected void doSetNextReader(LeafReaderContext context) throws
IOException {
- super.doSetNextReader(context);
- maxdoc = context.reader().maxDoc();
- spatialScorer = new SpatialScorer(context, weight, 1.0f);
- }
- }
-
-
- @Override
- public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode,
float boost) throws IOException {
- // if we were supposed to use bboxQuery, then we should have been
rewritten using that query
- assert bboxQuery == null;
- return new SpatialWeight(searcher, boost);
- }
-
-
- /** Prints a user-readable version of this query. */
- @Override
- public String toString(String field)
- {
- return super.getOptions() +
- (calcDist ? "geofilt" : "bbox") + "(latlonSource="+origField +"("
+ latSource + "," + lonSource + ")"
- +",latCenter="+latCenter+",lonCenter="+lonCenter
- +",dist=" + dist
- +",latMin=" + latMin + ",latMax="+latMax
- +",lonMin=" + lonMin + ",lonMax"+lonMax
- +",lon2Min=" + lon2Min + ",lon2Max" + lon2Max
- +",calcDist="+calcDist
- +",planetRadius="+planetRadius
- // + (bboxQuery == null ? "" : ",bboxQuery="+bboxQuery)
- +")";
- }
-
-
- /** Returns true if <code>o</code> is equal to this. */
- @Override
- public boolean equals(Object o) {
- if (!sameClassAs(o)) return false;
- SpatialDistanceQuery other = (SpatialDistanceQuery)o;
- return this.latCenter == other.latCenter
- && this.lonCenter == other.lonCenter
- && this.latMin == other.latMin
- && this.latMax == other.latMax
- && this.lonMin == other.lonMin
- && this.lonMax == other.lonMax
- && this.lon2Min == other.lon2Min
- && this.lon2Max == other.lon2Max
- && this.dist == other.dist
- && this.planetRadius == other.planetRadius
- && this.calcDist == other.calcDist
- && this.lonSource.equals(other.lonSource)
- && this.latSource.equals(other.latSource)
- ;
- }
-
- /** Returns a hash code value for this object. */
- @Override
- public int hashCode() {
- // don't bother making the hash expensive - the center latitude + min
longitude will be very unique
- long hash = classHash();
- hash = hash * 31 + Double.doubleToLongBits(latCenter);
- hash = hash * 31 + Double.doubleToLongBits(lonMin);
- return (int) (hash >> 32 + hash);
- }
-
- @Override
- public void visit(QueryVisitor visitor) {
- visitor.visitLeaf(this);
- }
-}
-
-
diff --git a/solr/core/src/java/org/apache/solr/schema/PointType.java
b/solr/core/src/java/org/apache/solr/schema/PointType.java
index a67b0ae..c28d7fa 100644
--- a/solr/core/src/java/org/apache/solr/schema/PointType.java
+++ b/solr/core/src/java/org/apache/solr/schema/PointType.java
@@ -40,7 +40,7 @@ import org.locationtech.spatial4j.distance.DistanceUtils;
/**
* A point type that indexes a point in an n-dimensional space as separate
fields and supports range queries.
- * See {@link LatLonType} for geo-spatial queries.
+ * See {@link LatLonPointSpatialField} for geo-spatial queries.
*/
public class PointType extends CoordinateFieldType implements SpatialQueryable
{
@@ -282,7 +282,7 @@ public class PointType extends CoordinateFieldType
implements SpatialQueryable {
@Override
public double getSphereRadius() {
- // This won't likely be used. You should probably be using LatLonType
instead if you felt the need for this.
+ // This won't likely be used. You should probably be using
LatLonPointSpatialField instead if you felt the need for this.
// This is here just for backward compatibility reasons.
return DistanceUtils.EARTH_MEAN_RADIUS_KM;
}
diff --git
a/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java
b/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java
deleted file mode 100644
index 006d8d2..0000000
--- a/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.schema;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.solr.legacy.LegacyFieldType;
-import org.apache.solr.legacy.PointVectorStrategy;
-
-/**
- * @see PointVectorStrategy
- * @deprecated use {@link LatLonPointSpatialField} instead
- */
-@Deprecated
-public class SpatialPointVectorFieldType extends
AbstractSpatialFieldType<PointVectorStrategy> implements SchemaAware {
-
- protected String numberFieldName = "tdouble";//in example schema defaults to
non-zero precision step -- a good choice
- private int precisionStep;
-
- @Override
- protected void init(IndexSchema schema, Map<String, String> args) {
- super.init(schema, args);
-
- String v = args.remove( "numberType" );
- if( v != null ) {
- numberFieldName = v;
- }
-
- }
-
- /**
- * Adds X and Y fields to the given schema for each field with this class as
its field type.
- *
- * {@inheritDoc}
- *
- * @param schema {@inheritDoc}
- *
- */
- @Override
- public void inform(IndexSchema schema) {
- FieldType fieldType = schema.getFieldTypeByName(numberFieldName);
- if( fieldType == null ) {
- throw new RuntimeException( "Can not find number field: "+
numberFieldName);
- }
- //TODO support other numeric types in the future
- if( !(fieldType instanceof TrieDoubleField) ) {
- throw new RuntimeException( "field type must be TrieDoubleField: "+
fieldType);
- }
- precisionStep = ((TrieField)fieldType).getPrecisionStep();
-
- // NOTE: the SchemaField constructor we're using ignores any properties of
the fieldType
- // so only the ones we're explicitly setting get used.
- //
- // In theory we should fix this, but since this class is already
deprecated, we'll leave it alone
- // to simplify the risk of back-compat break for existing users.
- final int p = (INDEXED | TOKENIZED | OMIT_NORMS | OMIT_TF_POSITIONS |
UNINVERTIBLE);
- List<SchemaField> newFields = new ArrayList<>();
- for( SchemaField sf : schema.getFields().values() ) {
- if( sf.getType() == this ) {
- String name = sf.getName();
- newFields.add(new SchemaField(name + PointVectorStrategy.SUFFIX_X,
fieldType, p, null));
- newFields.add(new SchemaField(name + PointVectorStrategy.SUFFIX_Y,
fieldType, p, null));
- }
- }
- for (SchemaField newField : newFields) {
- schema.getFields().put(newField.getName(), newField);
- }
- }
-
- @Override
- public NumberType getNumberType() {
- return NumberType.DOUBLE;
- }
-
- @Override
- protected PointVectorStrategy newSpatialStrategy(String fieldName) {
- // TODO update to how BBoxField does things
- if (this.getNumberType() != null) {
- // create strategy based on legacy numerics
- // todo remove in 7.0
- LegacyFieldType fieldType = new
LegacyFieldType(PointVectorStrategy.LEGACY_FIELDTYPE);
- fieldType.setNumericPrecisionStep(precisionStep);
- return new PointVectorStrategy(ctx, fieldName, fieldType);
- } else {
- return PointVectorStrategy.newInstance(ctx, fieldName);
- }
- }
-
-}
-
diff --git a/solr/core/src/java/org/apache/solr/schema/SpatialQueryable.java
b/solr/core/src/java/org/apache/solr/schema/SpatialQueryable.java
index 8d0c072..319fbda 100644
--- a/solr/core/src/java/org/apache/solr/schema/SpatialQueryable.java
+++ b/solr/core/src/java/org/apache/solr/schema/SpatialQueryable.java
@@ -22,7 +22,7 @@ import org.apache.solr.search.SpatialOptions;
/**
* Indicate that the implementing class is capable of generating a Query
against spatial resources.
- * For example, the LatLonType is capable of creating a query that restricts
the document space down
+ * For example, the {@link LatLonPointSpatialField} is capable of creating a
query that restricts the document space down
* to documents that are within a certain distance of a given point on Earth. *
*
**/
diff --git
a/solr/core/src/java/org/apache/solr/schema/SpatialTermQueryPrefixTreeFieldType.java
b/solr/core/src/java/org/apache/solr/schema/SpatialTermQueryPrefixTreeFieldType.java
deleted file mode 100644
index 203a7b8..0000000
---
a/solr/core/src/java/org/apache/solr/schema/SpatialTermQueryPrefixTreeFieldType.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.schema;
-
-import org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
-
-/**
- * @see TermQueryPrefixTreeStrategy
- * @deprecated use {@link
org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy} or {@link
RptWithGeometrySpatialField}
- */
-@Deprecated
-public class SpatialTermQueryPrefixTreeFieldType extends
AbstractSpatialPrefixTreeFieldType<TermQueryPrefixTreeStrategy> {
-
- @Override
- protected TermQueryPrefixTreeStrategy newPrefixTreeStrategy(String
fieldName) {
- return new TermQueryPrefixTreeStrategy(grid,fieldName);
- }
-}
-
diff --git
a/solr/core/src/java/org/apache/solr/search/SpatialFilterQParserPlugin.java
b/solr/core/src/java/org/apache/solr/search/SpatialFilterQParserPlugin.java
index cba3133..dbe4f24 100644
--- a/solr/core/src/java/org/apache/solr/search/SpatialFilterQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/SpatialFilterQParserPlugin.java
@@ -17,6 +17,8 @@
package org.apache.solr.search;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.schema.LatLonPointSpatialField;
+import org.apache.solr.schema.PointType;
/**
* Creates a spatial Filter based on the type of spatial point used.
@@ -34,14 +36,16 @@ import org.apache.solr.request.SolrQueryRequest;
* <li>pt - The point to use as a reference. Must match the dimension of the
field. Required.</li>
* <li>d - The distance in km. Required.</li>
* </ul>
- * The distance measure used currently depends on the FieldType. LatLonType
defaults to using haversine, PointType defaults to Euclidean (2-norm).
+ * The distance measure used currently depends on the FieldType.
+ * {@link LatLonPointSpatialField} defaults to using haversine,
+ * {@link PointType} defaults to Euclidean (2-norm).
* <p>
* Examples:
* <pre>fq={!geofilt sfield=store pt=10.312,-20.556 d=3.5}</pre>
* <pre>fq={!geofilt sfield=store}&pt=10.312,-20&d=3.5</pre>
* <pre>fq={!geofilt}&sfield=store&pt=10.312,-20&d=3.5</pre>
* <p>
- * Note: The geofilt for LatLonType is capable of also producing scores equal
to the computed distance from the point
+ * Note: The geofilt for {@link LatLonPointSpatialField} is capable of also
producing scores equal to the computed distance from the point
* to the field, making it useful as a component of the main query or a
boosting query.
*/
public class SpatialFilterQParserPlugin extends QParserPlugin {
diff --git
a/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
b/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
index 5c87c9b..fd88cff 100644
---
a/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
+++
b/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
@@ -133,7 +133,7 @@ public class GeoDistValueSourceParser extends
ValueSourceParser {
SpatialStrategyMultiValueSource spatialStrategyMultiValueSource =
findSpatialStrategyMultiValueSource(mv1, mv2);
if (spatialStrategyMultiValueSource != null) {
if (constants == null)
- throw new SyntaxError("When using AbstractSpatialFieldType (e.g. RPT
not LatLonType)," +
+ throw new SyntaxError("When using AbstractSpatialFieldType (e.g.
RPT)," +
" the point must be supplied as constants");
// note: uses Haversine by default but can be changed via distCalc=...
SpatialStrategy strategy = spatialStrategyMultiValueSource.strategy;
diff --git
a/solr/core/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
b/solr/core/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
index 44e7dd7..3086609 100644
---
a/solr/core/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
+++
b/solr/core/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
@@ -32,6 +32,7 @@ import java.io.IOException;
* <p>
* Note, there is no reciprocal function for this.
**/
+@Deprecated
public class GeohashFunction extends ValueSource {
protected ValueSource lat, lon;
diff --git
a/solr/core/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
b/solr/core/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
index e0a5279..b4057bd 100644
---
a/solr/core/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
+++
b/solr/core/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
@@ -38,7 +38,8 @@ import java.util.Map;
*
* @see org.apache.solr.search.function.distance.HaversineFunction for more
details on the implementation
*
- **/
+ */
+@Deprecated
public class GeohashHaversineFunction extends ValueSource {
private final ValueSource geoHash1, geoHash2;
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-hash.xml
b/solr/core/src/test-files/solr/collection1/conf/schema-hash.xml
index c2d6b39..e5dbd74 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-hash.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-hash.xml
@@ -376,17 +376,6 @@
<fieldType name="uuid" class="solr.UUIDField"/>
- <!-- Try out some point types -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
- <fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
- <!-- Use the sub field suffix -->
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldtype name="geohash" class="solr.GeoHashField"/>
-
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
-
<!-- some per-field similarity examples -->
<!-- specify a Similarity classname directly -->
@@ -439,21 +428,6 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
- <field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
- <field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
- <field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
-
<!-- test different combinations of indexed and stored -->
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
@@ -569,8 +543,6 @@
<dynamicField name="tv_mv_*" type="text" indexed="true" stored="true"
multiValued="true"
termVectors="true" termPositions="true" termOffsets="true"/>
- <dynamicField name="*_p" type="xyd" indexed="true" stored="true"
multiValued="false"/>
-
<!-- special fields for dynamic copyField test -->
<dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
<dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-minhash.xml
b/solr/core/src/test-files/solr/collection1/conf/schema-minhash.xml
index a13ba35..9465e83 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-minhash.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-minhash.xml
@@ -376,17 +376,6 @@
<fieldType name="uuid" class="solr.UUIDField"/>
- <!-- Try out some point types -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
- <fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
- <!-- Use the sub field suffix -->
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldtype name="geohash" class="solr.GeoHashField"/>
-
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
-
<!-- Min hash analysed field type -->
<fieldType name="text_min_hash" class="solr.TextField"
positionIncrementGap="100">
@@ -452,21 +441,6 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
- <field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
- <field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
- <field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
-
<!-- test different combinations of indexed and stored -->
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
@@ -585,8 +559,6 @@
<dynamicField name="tv_mv_*" type="text" indexed="true" stored="true"
multiValued="true"
termVectors="true" termPositions="true" termOffsets="true"/>
- <dynamicField name="*_p" type="xyd" indexed="true" stored="true"
multiValued="false"/>
-
<!-- special fields for dynamic copyField test -->
<dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
<dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
b/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
index 46b735c..66249e1 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
@@ -478,15 +478,6 @@
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>
- <!-- Poly field -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
-
<!-- Field type where english stopwords are managed by the REST API -->
<fieldType name="managed_en" class="solr.TextField"
autoGeneratePhraseQueries="false">
<analyzer>
@@ -638,12 +629,6 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
-
<!-- to test uniq fields -->
<field name="uniq" type="string" indexed="true" stored="true"
multiValued="true"/>
<field name="uniq2" type="string" indexed="true" stored="true"
multiValued="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
b/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
index 3f09e3a..ffb473b 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
@@ -22,7 +22,7 @@
<fieldType name="tfloat" class="${solr.tests.FloatFieldType}"
docValues="${solr.tests.numeric.dv}" precisionStep="8"/>
<fieldType name="tlong" class="${solr.tests.LongFieldType}"
docValues="${solr.tests.numeric.dv}" precisionStep="8"/>
- <!-- tdouble class can't be randomized, because SpatialPointVectorFieldType
requires TrieDoubleField. See SOLR-11111. -->
+ <!-- tdouble class can't be randomized, because BBoxField requires
TrieDoubleField. See SOLR-11111. -->
<fieldType name="tdouble" class="solr.TrieDoubleField"
docValues="${solr.tests.numeric.dv}" precisionStep="8"/>
<fieldType name="tdoubleDV" class="${solr.tests.DoubleFieldType}"
precisionStep="8" docValues="true"/>
@@ -33,6 +33,8 @@
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
+ <fieldType name="point2D" class="solr.PointType" dimension="2"
subFieldType="tdouble"/>
+
<fieldType name="srpt_geohash"
class="solr.SpatialRecursivePrefixTreeFieldType"
prefixTree="geohash" distanceUnits="degrees"
/>
@@ -45,14 +47,6 @@
<fieldType name="srpt_100km" class="solr.SpatialRecursivePrefixTreeFieldType"
maxDistErr="100" distanceUnits="kilometers"
/>
- <fieldType name="stqpt_geohash"
class="solr.SpatialTermQueryPrefixTreeFieldType"
- prefixTree="geohash" distanceUnits="degrees"/>
-
- <fieldType name="stqpt_u" class="solr.SpatialTermQueryPrefixTreeFieldType"
- geo="false" distCalculator="cartesian^2" worldBounds="ENVELOPE(0,
1000, 1000, 0)" distanceUnits="degrees"/>
-
- <fieldType name="pointvector" class="solr.SpatialPointVectorFieldType"
- numberType="tdouble" distanceUnits="degrees"/>
<fieldType name="srptgeom" class="solr.RptWithGeometrySpatialField"/>
@@ -82,8 +76,6 @@
<field name="srpt_geohash" type="srpt_geohash" multiValued="true"/>
<field name="srpt_quad" type="srpt_quad" multiValued="true"/>
<field name="srpt_packedquad" type="srpt_packedquad" multiValued="true"/>
- <field name="stqpt_geohash" type="stqpt_geohash" multiValued="true"/>
- <field name="pointvector" type="pointvector"/>
<field name="srptgeom" type="srptgeom"/>
<field name="srptgeom_geo3d" type="srptgeom_geo3d"/>
<field name="srptgeom_s2_geo3d" type="srptgeom_s2_geo3d"/>
@@ -103,6 +95,15 @@
<dynamicField name="bboxD_*" type="bbox" indexed="true"/>
<dynamicField name="str_*" type="string" indexed="true" stored="true"/>
+ <!-- for DistanceFunctionTest -->
+ <fieldType name="llp_km" class="solr.LatLonPointSpatialField"
distanceUnits="kilometers" />
+ <fieldType name="srpt_geohash_km"
class="solr.SpatialRecursivePrefixTreeFieldType"
+ geo="true" prefixTree="geohash" distanceUnits="kilometers"
+ />
+ <field name="srpt_geohash_km" type="srpt_geohash_km"/>
+ <field name="llp_km" type="llp_km" docValues="true"/>
+ <dynamicField name="*_td" type="tdouble" indexed="true" stored="true"/>
+ <field name="point" type="point2D" indexed="true" stored="true"
multiValued="false"/>
<uniqueKey>id</uniqueKey>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-sql.xml
b/solr/core/src/test-files/solr/collection1/conf/schema-sql.xml
index 03d9d7e..7b5e2ae 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-sql.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-sql.xml
@@ -386,17 +386,6 @@
<fieldType name="uuid" class="solr.UUIDField"/>
- <!-- Try out some point types -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
- <fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
- <!-- Use the sub field suffix -->
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldtype name="geohash" class="solr.GeoHashField"/>
-
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
-
<!-- some per-field similarity examples -->
<!-- specify a Similarity classname directly -->
@@ -456,21 +445,6 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
- <field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
- <field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
- <field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
-
<!-- test different combinations of indexed and stored -->
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
@@ -586,8 +560,6 @@
<dynamicField name="tv_mv_*" type="text" indexed="true" stored="true"
multiValued="true"
termVectors="true" termPositions="true" termOffsets="true"/>
- <dynamicField name="*_p" type="xyd" indexed="true" stored="true"
multiValued="false"/>
-
<!-- special fields for dynamic copyField test -->
<dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
<dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema.xml
b/solr/core/src/test-files/solr/collection1/conf/schema.xml
index c55d86b..d6b14bb 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema.xml
@@ -428,10 +428,6 @@
<fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
<fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
<fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
<!-- Currency type -->
<fieldType name="currency" class="solr.CurrencyField"
currencyConfig="currency.xml" multiValued="false"/>
@@ -461,7 +457,7 @@
</analyzer>
</fieldType>
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
+ <fieldType name="location" class="solr.LatLonPointSpatialField" />
<!--
Example of using PathHierarchyTokenizerFactory at index time, so
@@ -565,22 +561,13 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
+ <!-- Test spatial PointType -->
<field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
<field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
<field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
<field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
<field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="work_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
<!-- Test currency -->
<field name="amount" type="currency" indexed="true" stored="true"
multiValued="false"/>
<field name="mock_amount" type="mock_currency" indexed="true" stored="true"/>
@@ -697,7 +684,7 @@
<field name="title_stringNoNorms" type="string" omitNorms="true"
indexed="true" stored="true"/>
- <field name="store" type="location" indexed="true" stored="true"
omitNorms="false"/>
+ <field name="store" type="location" indexed="true" stored="true"
docValues="true"/>
<field name="lower" type="lowerfilt" indexed="false" stored="true"
multiValued="true"/>
<field name="_route_" type="string" indexed="true" stored="true"
multiValued="false"/>
@@ -788,7 +775,7 @@
<dynamicField name="*_mfacet" type="string" indexed="true" stored="false"
multiValued="true"/>
- <!-- Type used to index the lat and lon components for the "location"
FieldType -->
+ <!-- Type used to index the components for the "point" FieldType -->
<dynamicField name="*_coordinate" type="double" indexed="true"
stored="false" omitNorms="true" docValues="false"/>
<dynamicField name="*_path" type="path" indexed="true" stored="true"
omitNorms="true" multiValued="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema11.xml
b/solr/core/src/test-files/solr/collection1/conf/schema11.xml
index f4c90c8..7ec3015 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema11.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema11.xml
@@ -240,17 +240,6 @@
<fieldType name="tdates" class="${solr.tests.DateFieldType}"
docValues="${solr.tests.numeric.dv}" omitNorms="true" positionIncrementGap="0"
precisionStep="0" multiValued="true" />
- <!-- Poly field -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
-
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multi
-valued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
-
<!-- eff_tint class can't be randomized, because ExternalFileField disallows
point-based keyField. See SOLR-10846. -->
<fieldType name="eff_tint" class="solr.TrieDoubleField"
docValues="${solr.tests.numeric.dv}" precisionStep="8"/>
<field name="eff_tint" type="eff_tint" indexed="true" stored="true"/>
@@ -293,12 +282,6 @@ valued. -->
<copyField source="id" dest="id_i" />
<field name="text" type="text" indexed="true" stored="false" />
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
<field name="signatureField" type="string" indexed="true" stored="false"/>
<field name="eff_trie" type="eff_tfloat" />
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema12.xml
b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
index 33468f9..5e67304 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema12.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
@@ -553,17 +553,7 @@
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>
- <!-- Poly field -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
- <!-- sub-centimeter accuracy for RPT; distance calcs -->
- <fieldType name="location_rpt"
class="solr.SpatialRecursivePrefixTreeFieldType"
- geo="true" distErrPct="0.025" maxDistErr="0.00001"
distanceUnits="kilometers"/>
+ <fieldType name="location" class="solr.LatLonPointSpatialField" />
<fieldType name="currency" class="solr.CurrencyField"
currencyConfig="currency.xml" multiValued="false"/>
@@ -661,12 +651,7 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
- <field name="store_rpt" type="location_rpt" indexed="true" stored="false"/>
+ <field name="store" type="location" indexed="true" stored="true"
docValues="true"/>
<!-- Test currency field -->
<field name="amount_c" type="currency" indexed="true" stored="true"
multiValued="false"/>
@@ -686,8 +671,6 @@
-->
<!-- <field name="_version_" type="long" indexed="true" stored="true"/> -->
- <dynamicField name="*_coordinate" type="tdouble" indexed="true"
stored="false"/>
-
<dynamicField name="*_sI" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
<dynamicField name="t_pick_best_*" type="text_pick_best" indexed="true"
stored="true"/>
@@ -807,6 +790,5 @@
<copyField source="subject" dest="text"/>
<copyField source="foo_copysource_*" dest="bar_copydest_*"/>
- <copyField source="store" dest="store_rpt"/>
</schema>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema15.xml
b/solr/core/src/test-files/solr/collection1/conf/schema15.xml
index b585df5..c5b90a0 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema15.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema15.xml
@@ -437,14 +437,8 @@
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>
- <!-- Poly field -->
+ <fieldType name="location" class="solr.LatLonPointSpatialField"/>
<fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
<fieldType name="text_min_hash" class="solr.TextField"
positionIncrementGap="100">
<analyzer>
@@ -540,11 +534,9 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
+ <field name="xy" type="xy" indexed="true" stored="true" multiValued="false"/>
+ <field name="store" type="location" indexed="true" stored="true"
docValues="true"/>
+
<field name="amount" type="currency" indexed="true" stored="true"
multiValued="false"/>
<!-- to test uniq fields -->
@@ -567,8 +559,6 @@
<field name="min_hash_analysed" type="text_min_hash" multiValued="false"
indexed="true" stored="false"/>
- <dynamicField name="*_coordinate" type="tdouble" indexed="true"
stored="false"/>
-
<dynamicField name="*_sI" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
<dynamicField name="t_*" type="text" indexed="true" stored="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema_latest.xml
b/solr/core/src/test-files/solr/collection1/conf/schema_latest.xml
index 9d48541..746b530 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema_latest.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema_latest.xml
@@ -240,9 +240,6 @@
<dynamicField name="*_txt" type="text_general" indexed="true" stored="true"
multiValued="true"/>
<dynamicField name="*_en" type="text_en" indexed="true" stored="true"
multiValued="true"/>
- <!-- Type used to index the lat and lon components for the "location"
FieldType -->
- <dynamicField name="*_coordinate" type="tdouble" indexed="true"
stored="false"/>
-
<dynamicField name="*_p" type="location" indexed="true" stored="true"/>
<!-- some trie-coded dynamic fields for faster range queries -->
@@ -715,25 +712,19 @@
any data added to them will be ignored outright. -->
<fieldtype name="ignored" stored="false" indexed="false" docValues="false"
multiValued="true" class="solr.StrField"/>
- <!-- This point type indexes the coordinates as separate fields (subFields)
- If subFieldType is defined, it references a type, and a dynamic field
- definition is created matching *___<typename>. Alternately, if
- subFieldSuffix is defined, that is used to create the subFields.
- Example: if subFieldType="double", then the coordinates would be
- indexed in fields myloc_0___double,myloc_1___double.
- Example: if subFieldSuffix="_d" then the coordinates would be indexed
- in fields myloc_0_d,myloc_1_d
- The subFields are an implementation detail of the fieldType, and end
- users normally should not need to know about them.
- -->
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
-
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
-
- <fieldType name="location_rpt"
class="solr.SpatialRecursivePrefixTreeFieldType"
- geo="true" distErrPct="0.025" maxDistErr="0.001"
distanceUnits="kilometers"/>
-
+ <fieldType name="location" class="solr.LatLonPointSpatialField" />
+
+ <!-- Money/currency field type. See
http://wiki.apache.org/solr/MoneyFieldType
+ Parameters:
+ defaultCurrency: Specifies the default currency if none specified.
Defaults to "USD"
+ precisionStep: Specifies the precisionStep for the TrieLong field
used for the amount
+ providerClass: Lets you plug in other exchange provider backend:
+ solr.FileExchangeRateProvider is the default and
takes one parameter:
+ currencyConfig: name of an xml file holding
exchange rates
+ solr.OpenExchangeRatesOrgProvider uses rates from
openexchangerates.org:
+ ratesFileLocation: URL or path to rates JSON file
(default latest.json on the web)
+ refreshInterval: Number of minutes between each
rates fetch (default: 1440, min: 60)
+ -->
<fieldType name="currency" class="solr.CurrencyField" precisionStep="8"
defaultCurrency="USD"
currencyConfig="currency.xml"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml
b/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml
index 93b11ed..95045be 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml
@@ -450,15 +450,6 @@
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>
- <!-- Poly field -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
-
<field name="id" type="string" indexed="true" stored="true"
multiValued="false" required="true"/>
<field name="signatureField" type="string" indexed="true" stored="false"/>
<field name="uuid" type="uuid" stored="true"/>
@@ -543,12 +534,6 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
-
<!-- to test uniq fields -->
<field name="uniq" type="string" indexed="true" stored="true"
multiValued="true"/>
<field name="uniq2" type="string" indexed="true" stored="true"
multiValued="true"/>
@@ -557,8 +542,6 @@
<field name="_version_" type="long" indexed="true" stored="true"
multiValued="false"/>
- <dynamicField name="*_coordinate" type="tdouble" indexed="true"
stored="false"/>
-
<dynamicField name="*_sI" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
<dynamicField name="t_*" type="text" indexed="true" stored="true"/>
diff --git
a/solr/core/src/test-files/solr/configsets/cloud-dynamic/conf/schema.xml
b/solr/core/src/test-files/solr/configsets/cloud-dynamic/conf/schema.xml
index 5e2719d..06f1973 100644
--- a/solr/core/src/test-files/solr/configsets/cloud-dynamic/conf/schema.xml
+++ b/solr/core/src/test-files/solr/configsets/cloud-dynamic/conf/schema.xml
@@ -163,12 +163,8 @@
<!-- Poly field -->
<fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
+ <fieldType name="location" class="solr.LatLonPointSpatialField" />
<fieldType class="org.apache.solr.schema.SortableBinaryField"
name="sortable_binary"/>
@@ -217,11 +213,9 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
<field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
+
+ <field name="store" type="location" indexed="true" stored="true"
docValues="true"/>
<!-- to test uniq fields -->
<field name="uniq" type="string" indexed="true" stored="true"
multiValued="true"/>
@@ -244,8 +238,6 @@
<field name="multi_int_with_docvals" type="tint" multiValued="true"
docValues="true" indexed="false"/>
- <dynamicField name="*_coordinate" type="tdouble" indexed="true"
stored="false"/>
-
<dynamicField name="*_sI" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
<dynamicField name="t_*" type="text" indexed="true" stored="true"/>
diff --git
a/solr/core/src/test-files/solr/configsets/doc-expiry/conf/schema.xml
b/solr/core/src/test-files/solr/configsets/doc-expiry/conf/schema.xml
index ab720bd..5afe412 100644
--- a/solr/core/src/test-files/solr/configsets/doc-expiry/conf/schema.xml
+++ b/solr/core/src/test-files/solr/configsets/doc-expiry/conf/schema.xml
@@ -161,16 +161,6 @@
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>
- <!-- Poly field -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
-
-
<field name="id" type="string" indexed="true" stored="true"
multiValued="false" required="true"/>
<field name="signatureField" type="string" indexed="true" stored="false"/>
<field name="uuid" type="uuid" stored="true"/>
@@ -216,12 +206,6 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
-
<!-- to test uniq fields -->
<field name="uniq" type="string" indexed="true" stored="true"
multiValued="true"/>
<field name="uniq2" type="string" indexed="true" stored="true"
multiValued="true"/>
@@ -238,8 +222,6 @@
<field name="multi_int_with_docvals" type="tint" multiValued="true"
docValues="true" indexed="false"/>
- <dynamicField name="*_coordinate" type="tdouble" indexed="true"
stored="false"/>
-
<dynamicField name="*_sI" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
<dynamicField name="t_*" type="text" indexed="true" stored="true"/>
diff --git a/solr/core/src/test-files/solr/configsets/sql/conf/schema.xml
b/solr/core/src/test-files/solr/configsets/sql/conf/schema.xml
index a945d2e..a414d9c 100644
--- a/solr/core/src/test-files/solr/configsets/sql/conf/schema.xml
+++ b/solr/core/src/test-files/solr/configsets/sql/conf/schema.xml
@@ -204,15 +204,6 @@
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>
- <!-- Poly field -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="*_d"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
- <fieldType name="point" class="solr.PointType" dimension="2"
subFieldSuffix="_d"/>
- <!-- A specialized field for geospatial search. If indexed, this fieldType
must not be multivalued. -->
- <fieldType name="location" class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
-
<fieldType class="org.apache.solr.schema.SortableBinaryField"
name="sortable_binary"/>
<field name="id" type="string" indexed="true" stored="true"
multiValued="false" docValues="true" required="true"/>
@@ -260,12 +251,6 @@
-->
<field name="timestamp" type="date" indexed="true" stored="true"/>
- <!-- Test a point field for distances -->
- <field name="point" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="pointD" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="point_hash" type="geohash" indexed="true" stored="true"
multiValued="false"/>
- <field name="store" type="location" indexed="true" stored="true"/>
-
<!-- to test uniq fields -->
<field name="uniq" type="string" indexed="true" stored="true"
multiValued="true"/>
<field name="uniq2" type="string" indexed="true" stored="true"
multiValued="true"/>
diff --git a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
index d32ba1a..fd12ec6 100644
--- a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
+++ b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
@@ -336,7 +336,7 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
);
assertJQ(
- req("q", "*:*", "sort", "geodist(45.18014,-93.87742,store) asc",
"rows", "1", "group", "true", "group.field", "id", "fl", "id"),
+ req("q", "*:*", "sort", "geodist(45.18014,-93.87742) asc", "sfield",
"store", "rows", "1", "group", "true", "group.field", "id", "fl", "id"),
"/grouped=={'id':{'matches':5,'groups':[{'groupValue':'1','doclist':{'numFound':1,'start':0,numFoundExact:true,'docs':[{'id':'1'}]}}]}}"
);
}
@@ -635,7 +635,7 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
"rows","1",
"fl","id", "group.limit","2")
,"/grouped/id:[2 TO
5]=={'matches':10,'doclist':{'numFound':4,'start':0,numFoundExact:true,'docs':[{'id':'3'},{'id':'4'}]}}"
- ,"/grouped/id:[5 TO
5]=={'matches':10,'doclist':{'numFound':1,'start':0,numFoundExact:true,'docs':[{'id':'5'}]}}"
+ ,"/grouped/id:[5 TO
5]=={'matches':10,'doclist':{'numFound':1,'start':0,numFoundExact:true,'docs':[{'id':'5'}]}}"
,"/grouped/"+f+"=={'matches':10,'groups':[{'groupValue':1,'doclist':{'numFound':3,'start':0,numFoundExact:true,'docs':[{'id':'8'},{'id':'10'}]}}]}"
);
@@ -682,7 +682,7 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
"rows","1",
"fl","id", "group.limit","2")
,"/grouped/id:[2 TO
5]=={'matches':0,'doclist':{'numFound':0,'start':0,numFoundExact:true,'docs':[]}}"
- ,"/grouped/id:[5 TO
5]=={'matches':0,'doclist':{'numFound':0,'start':0,numFoundExact:true,'docs':[]}}"
+ ,"/grouped/id:[5 TO
5]=={'matches':0,'doclist':{'numFound':0,'start':0,numFoundExact:true,'docs':[]}}"
,"/grouped/"+f+"=={'matches':0,'groups':[]}"
);
assertJQ(req("fq",filt,
@@ -952,7 +952,7 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
} // end index iter
}
-
+
@Test
public void testGroupWithMinExactHitCount() throws Exception {
final int NUM_DOCS = 20;
@@ -970,12 +970,12 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
assertQ(req(params)
,"/response/lst[@name='grouped']/lst[@name='"+FOO_STRING_FIELD+"']/arr[@name='groups']/lst[1]/result[@numFoundExact='true']"
);
-
+
assertQ(req(params, CommonParams.MIN_EXACT_COUNT, "2", CommonParams.ROWS,
"2")
,"/response/lst[@name='grouped']/lst[@name='"+FOO_STRING_FIELD+"']/arr[@name='groups']/lst[1]/result[@numFoundExact='true']"
);
-
-
+
+
}
public static Object buildGroupedResult(IndexSchema schema, List<Grp>
sortedGroups, int start, int rows, int group_offset, int group_limit, boolean
includeNGroups) {
diff --git
a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
index 0011ea0..c7998e0 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
@@ -625,8 +625,6 @@ public class CollectionsAPISolrJTest extends
SolrCloudTestCase {
doc.addField("number_tl", i);
doc.addField("number_tf", i);
doc.addField("number_td", i);
- doc.addField("point", i + "," + i);
- doc.addField("pointD", i + "," + i);
doc.addField("store", (i * 5) + "," + (i * 5));
doc.addField("boolean_b", true);
doc.addField("multi_int_with_docvals", i);
diff --git
a/solr/core/src/test/org/apache/solr/response/TestGeoJSONResponseWriter.java
b/solr/core/src/test/org/apache/solr/response/TestGeoJSONResponseWriter.java
index 99e2c50..df26c9c 100644
--- a/solr/core/src/test/org/apache/solr/response/TestGeoJSONResponseWriter.java
+++ b/solr/core/src/test/org/apache/solr/response/TestGeoJSONResponseWriter.java
@@ -49,8 +49,7 @@ public class TestGeoJSONResponseWriter extends SolrTestCaseJ4
{
// <field name="srpt_geohash" type="srpt_geohash" multiValued="true" />
// <field name="" type="srpt_quad" multiValued="true" />
// <field name="" type="srpt_packedquad" multiValued="true" />
-// <field name="" type="stqpt_geohash" multiValued="true" />
-
+
// multiple valued field
assertU(adoc("id","H.A", "srpt_geohash","POINT( 1 2 )"));
assertU(adoc("id","H.B", "srpt_geohash","POINT( 1 2 )",
@@ -140,7 +139,7 @@ public class TestGeoJSONResponseWriter extends
SolrTestCaseJ4 {
"wt","geojson",
"rows","2",
"fl","*",
- "geojson.field", "stqpt_geohash",
+ "geojson.field", "srptgeom",
"indent","true"));
// Check that we have a normal solr response with 'responseHeader' and
'response'
@@ -154,7 +153,7 @@ public class TestGeoJSONResponseWriter extends
SolrTestCaseJ4 {
"rows","2",
"fl","*",
"omitHeader", "true",
- "geojson.field", "stqpt_geohash",
+ "geojson.field", "srptgeom",
"indent","true"));
// Check that we have a normal solr response with 'responseHeader' and
'response'
@@ -173,7 +172,7 @@ public class TestGeoJSONResponseWriter extends
SolrTestCaseJ4 {
"q","*:*",
"wt","geojson",
"fl","*",
- "geojson.field", "stqpt_geohash",
+ "geojson.field", "srpt_geohash",
"indent","true")));
// Multivalued Valued Point
diff --git
a/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
b/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
index bdd3cd2..19d0420 100644
---
a/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
+++
b/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
@@ -15,8 +15,13 @@
* limitations under the License.
*/
package org.apache.solr.rest.schema;
+
import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.solr.client.solrj.request.schema.SchemaRequest;
import org.apache.solr.rest.SolrRestletTestBase;
import org.junit.Test;
@@ -73,17 +78,14 @@ public class TestFieldCollectionResource extends
SolrRestletTestBase {
@Test
public void testGetAllFieldsIncludeDynamic() throws Exception {
- assertJQ("/schema/fields?includeDynamic=true",
- "/fields/[0]/name=='HTMLstandardtok'",
- "/fields/[1]/name=='HTMLwhitetok'",
- "/fields/[2]/name=='_version_'",
- "/fields/[107]/name=='*_d'",
- "/fields/[106]/name=='*_f'",
- "/fields/[105]/name=='*_b'",
- "/fields/[104]/name=='*_t'",
- "/fields/[103]/name=='*_l'"
-
- );
+ List<Map<String, Object>> fields = new
SchemaRequest.Fields(params("includeDynamic", "true"))
+ .process(getSolrClient())
+ .getFields();
+
+ Set<String> lookingForNames = asSet("HTMLstandardtok", "HTMLwhitetok",
"_version_", // static
+ "*_d", "*_f", "*_b", "*_t", "*_l"); // dynamic
+ fields.stream().map(f -> f.get("name")).forEach(lookingForNames::remove);
+ assertTrue(lookingForNames.toString(), lookingForNames.isEmpty());
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
index 1d65406..95c311a 100644
--- a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
+++ b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
@@ -460,15 +460,10 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
"{!"+type+"}");
// diff SpatialQueryable FieldTypes matter for determining final query
assertQueryEquals(type, req,
- "{!"+type+" sfield=point_hash}",
- "{!"+type+" sfield=point_hash d=109}",
- "{!"+type+" sfield=point_hash d=$d pt=$pt}",
- "{!"+type+" sfield=point_hash d=$d
pt=10.312,-20.556}");
- assertQueryEquals(type, req,
- "{!"+type+" sfield=point}",
- "{!"+type+" sfield=point d=109}",
- "{!"+type+" sfield=point d=$d pt=$pt}",
- "{!"+type+" sfield=point d=$d pt=10.312,-20.556}");
+ "{!"+type+" sfield=xy}",
+ "{!"+type+" sfield=xy d=109}",
+ "{!"+type+" sfield=xy d=$d pt=$pt}",
+ "{!"+type+" sfield=xy d=$d pt=10.312,-20.556}");
} finally {
req.close();
}
@@ -787,17 +782,20 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
}
public void testFuncGeodist() throws Exception {
- SolrQueryRequest req = req("pt","10.312,-20.556",
- "sfield","store");
- try {
+ String pt = "10.312,-20.556";
+ try (SolrQueryRequest req = req("pt", pt,
+ "sfield", "store")) {
+
assertFuncEquals(req,
- "geodist()",
- "geodist($sfield,$pt)",
- "geodist(store,$pt)",
- "geodist(field(store),$pt)",
- "geodist(store,10.312,-20.556)");
- } finally {
- req.close();
+ "geodist($pt)",
+ "geodist(" + pt + ")",
+ "geodist(" + pt + "," + pt + ")");
+
+ assertFuncEquals(req,
+ "geodist()");
+ // geodist() does not support field names in its arguments sometimes
+ // "geodist(store,$pt)",
+ // "geodist(field(store),$pt)",
}
}
@@ -805,8 +803,8 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
assertFuncEquals("hsin(45,true,0,0,45,45)");
}
public void testFuncGhhsin() throws Exception {
- assertFuncEquals("ghhsin(45,point_hash,'asdf')",
- "ghhsin(45,field(point_hash),'asdf')");
+ assertFuncEquals("ghhsin(45,id,'asdf')",
+ "ghhsin(45,field(id),'asdf')");// "id" is just a
single-valued string field
}
public void testFuncGeohash() throws Exception {
assertFuncEquals("geohash(45,99)");
diff --git a/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
b/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
index 71354ab..3e5f787 100644
--- a/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
+++ b/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
@@ -277,11 +277,11 @@ public class ReturnFieldsTest extends SolrTestCaseJ4 {
assertFalse(rf.wantsAllFields());
assertNull(rf.getTransformer());
- // Don't return 'store_rpt' just because it is required by the transformer
- rf = new SolrReturnFields( req("fl", "[geo f=store_rpt]") );
+ // Don't return 'store' just because it is required by the transformer
+ rf = new SolrReturnFields( req("fl", "[geo f=store]") );
assertFalse( rf.wantsScore() );
assertTrue(rf.wantsField("[geo]"));
- assertFalse( rf.wantsField( "store_rpt" ) );
+ assertFalse( rf.wantsField( "store" ) );
assertFalse(rf.wantsAllFields());
assertNotNull(rf.getTransformer());
}
@@ -395,8 +395,8 @@ public class ReturnFieldsTest extends SolrTestCaseJ4 {
final StringBuilder allFieldNames = new StringBuilder();
docIn.add(new StringField("id","bar",Store.YES));
allFieldNames.append("id");
- docIn.add(new StringField("store_rpt","42",Store.YES));
- allFieldNames.append(",store_rpt");
+ docIn.add(new StringField("store","42",Store.YES));
+ allFieldNames.append(",store");
docIn.add(new StringField("subword","bar",Store.YES)); // single value in
multi-value field
allFieldNames.append(",subword");
docIn.add(new StringField("uniq","xxx",Store.YES));
@@ -420,17 +420,17 @@ public class ReturnFieldsTest extends SolrTestCaseJ4 {
// behavior should be ultimately be consistent for all of these
ReturnField instances
// (aliasing, extra requested by transformer, or otherwise)
for (ReturnFields rf : Arrays.asList
- (new
SolrReturnFields(req("fl","id,subword,store_rpt,uniq,foo_2_s1")),
- new SolrReturnFields(req("fl","id,xxx:[geo
f=store_rpt],uniq,foo_2_s1,subword")),
- new
SolrReturnFields(req("fl","id,xxx:subword,uniq,yyy:foo_2_s1,[geo
f=store_rpt]")))) {
+ (new SolrReturnFields(req("fl","id,subword,store,uniq,foo_2_s1")),
+ new SolrReturnFields(req("fl","id,xxx:[geo
f=store],uniq,foo_2_s1,subword")),
+ new
SolrReturnFields(req("fl","id,xxx:subword,uniq,yyy:foo_2_s1,[geo f=store]")))) {
docOut = convertLuceneDocToSolrDoc(docIn, schema, rf);
final String debug = rf.toString() + " => " +docOut.toString();
assertEquals(debug, 5, docOut.size());
assertEquals(debug,
- new
HashSet<String>(Arrays.asList("id","subword","uniq","foo_2_s1","store_rpt")),
+ new
HashSet<String>(Arrays.asList("id","subword","uniq","foo_2_s1","store")),
docOut.getFieldNames());
assertTrue(debug, docOut.get("id") instanceof StringField);
- assertTrue(debug, docOut.get("store_rpt") instanceof StringField);
+ assertTrue(debug, docOut.get("store") instanceof StringField);
assertTrue(debug, docOut.get("foo_2_s1") instanceof StringField);
assertTrue(debug, docOut.get("subword") instanceof List);
assertTrue(debug, docOut.get("uniq") instanceof List);
@@ -451,7 +451,7 @@ public class ReturnFieldsTest extends SolrTestCaseJ4 {
final String debug = rf.toString() + " => " +docOut.toString();
assertEquals(debug, 24, docOut.size());
assertTrue(debug, docOut.get("id") instanceof StringField);
- assertTrue(debug, docOut.get("store_rpt") instanceof StringField);
+ assertTrue(debug, docOut.get("store") instanceof StringField);
assertTrue(debug, docOut.get("subword") instanceof List);
assertTrue(debug, docOut.get("uniq") instanceof List);
for (int i = 0; i < 20; i++) {
diff --git a/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java
b/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java
index 66034c9..84b7d1f 100644
--- a/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java
+++ b/solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java
@@ -61,25 +61,10 @@ public class SpatialFilterTest extends SolrTestCaseJ4 {
//large distance
checkHits(fieldName, "33.0,-80.0", 5000, 13);
}
-
- @Test
- public void testGeoHash() throws Exception {
- String fieldName = "home_gh";
- setupDocs(fieldName);
- //try some normal cases
- checkHits(fieldName, "33.0,-80.0", 300, 2, 1, 2);
- //large distance
- checkHits(fieldName, "33.0,-80.0", 5000, 2, 1, 2);
- //Try some edge cases
- checkHits(fieldName, "0,179.8", 200, 2);
- checkHits(fieldName, "1,1", 180, 3, 5, 6, 7);
- checkHits(fieldName, "89.8, 50", 200, 2);
- checkHits(fieldName, "-89.8, 50", 200, 2);//this goes over the south pole
- }
@Test
public void testLatLonType() throws Exception {
- String fieldName = "home_ll";
+ String fieldName = "store";
setupDocs(fieldName);
//Try some edge cases
checkHits(fieldName, "1,1", 175, 3, 5, 6, 7);
@@ -118,8 +103,8 @@ public class SpatialFilterTest extends SolrTestCaseJ4 {
// Tests SOLR-2829
- String fieldNameHome = "home_ll";
- String fieldNameWork = "work_ll";
+ String fieldNameHome = "home";
+ String fieldNameWork = "work";
clearIndex();
assertU(adoc("id", "1", fieldNameHome, "52.67,7.30",
fieldNameWork,"48.60,11.61"));
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java
b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java
index 7722664..6a7bcc6 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java
@@ -53,7 +53,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
@ParametersFactory
public static Iterable<Object[]> parameters() {
return Arrays.asList(new Object[][]{
- {"llp"}, {"llp_idx"}, {"llp_dv"}, {"srpt_geohash"}, {"srpt_quad"},
{"srpt_packedquad"}, {"stqpt_geohash"}, {"pointvector"}, {"bbox"}, {"pbbox"},
{"bbox_ndv"}
+ {"llp"}, {"llp_idx"}, {"llp_dv"}, {"srpt_geohash"}, {"srpt_quad"},
{"srpt_packedquad"}, {"bbox"}, {"pbbox"}, {"bbox_ndv"}
});
}
@@ -392,8 +392,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
@Test
public void testSortMultiVal() throws Exception {
assumeTrue("dist sorting not supported on field " + fieldName,
canCalcDistance);
- assumeFalse("Multivalue not supported for this field",
- fieldName.equals("pointvector") || isBBoxField(fieldName));
+ assumeFalse("Multivalue not supported for this field",
isBBoxField(fieldName));
assertU(adoc("id", "100", fieldName, "1,2"));//1 point
assertU(adoc("id", "101", fieldName, "4,-1", fieldName, "3,5"));//2
points, 2nd is pretty close to query point
diff --git
a/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java
b/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java
index 7056064..3b1c228 100644
--- a/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java
@@ -47,9 +47,9 @@ public class TestValueSourceCache extends SolrTestCaseJ4 {
// This is actually also tested by the tests for val_d1 below, but the bug
was reported against geodist()...
@Test
public void testGeodistSource() throws SyntaxError {
- Query q_home = getQuery("geodist(home_ll, 45.0, 43.0)");
- Query q_work = getQuery("geodist(work_ll, 45.0, 43.0)");
- Query q_home2 = getQuery("geodist(home_ll, 45.0, 43.0)");
+ Query q_home = getQuery("geodist(home, 45.0, 43.0)");
+ Query q_work = getQuery("geodist(work, 45.0, 43.0)");
+ Query q_home2 = getQuery("geodist(home, 45.0, 43.0)");
QueryUtils.checkUnequal(q_work, q_home);
QueryUtils.checkEqual(q_home, q_home2);
}
diff --git
a/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
b/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
index b3ad183..3deffc7 100644
---
a/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
+++
b/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
@@ -15,8 +15,7 @@
* limitations under the License.
*/
package org.apache.solr.search.function.distance;
-import org.locationtech.spatial4j.distance.DistanceUtils;
-import org.locationtech.spatial4j.io.GeohashUtils;
+
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.junit.BeforeClass;
@@ -29,21 +28,19 @@ import org.junit.Test;
public class DistanceFunctionTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
- System.setProperty("enable.update.log", "false"); // schema12 doesn't
support _version_
- initCore("solrconfig.xml", "schema12.xml");
+ initCore("solrconfig-minimal.xml", "schema-spatial.xml");
}
@Test
public void testHaversine() throws Exception {
clearIndex();
- assertU(adoc("id", "1", "x_td", "0", "y_td", "0", "gh_s1",
GeohashUtils.encodeLatLon(32.7693246, -79.9289094)));
- assertU(adoc("id", "2", "x_td", "0", "y_td", String.valueOf(Math.PI / 2),
"gh_s1", GeohashUtils.encodeLatLon(32.7693246, -78.9289094)));
- assertU(adoc("id", "3", "x_td", String.valueOf(Math.PI / 2), "y_td",
String.valueOf(Math.PI / 2), "gh_s1", GeohashUtils.encodeLatLon(32.7693246,
-80.9289094)));
- assertU(adoc("id", "4", "x_td", String.valueOf(Math.PI / 4), "y_td",
String.valueOf(Math.PI / 4), "gh_s1", GeohashUtils.encodeLatLon(32.7693246,
-81.9289094)));
- assertU(adoc("id", "5", "x_td", "45.0", "y_td", "45.0",
- "gh_s1", GeohashUtils.encodeLatLon(32.7693246, -81.9289094)));
- assertU(adoc("id", "6", "point_hash", "32.5, -79.0", "point", "32.5,
-79.0"));
- assertU(adoc("id", "7", "point_hash", "32.6, -78.0", "point", "32.6,
-78.0"));
+ assertU(adoc("id", "1", "x_td", "0", "y_td", "0"));
+ assertU(adoc("id", "2", "x_td", "0", "y_td", String.valueOf(Math.PI / 2)));
+ assertU(adoc("id", "3", "x_td", String.valueOf(Math.PI / 2), "y_td",
String.valueOf(Math.PI / 2)));
+ assertU(adoc("id", "4", "x_td", String.valueOf(Math.PI / 4), "y_td",
String.valueOf(Math.PI / 4)));
+ assertU(adoc("id", "5", "x_td", "45.0", "y_td", "45.0"));
+ assertU(adoc("id", "6", "point", "32.5, -79.0"));
+ assertU(adoc("id", "7", "point", "32.6, -78.0"));
assertU(commit());
//Get the haversine distance between the point 0,0 and the docs above
assuming a radius of 1
assertQ(req("fl", "*,score", "q", "{!func}hsin(1, false, x_td, y_td, 0,
0)", "fq", "id:1"), "//float[@name='score']='0.0'");
@@ -53,36 +50,23 @@ public class DistanceFunctionTest extends SolrTestCaseJ4 {
assertQ(req("fl", "*,score", "q", "{!func}hsin(1, true, x_td, y_td, 0,
0)", "fq", "id:5"), "//float[@name='score']='1.0471976'");
//SOLR-2114
assertQ(req("fl", "*,score", "q", "{!func}hsin(6371.009, true, point,
vector(0, 0))", "fq", "id:6"), "//float[@name='score']='8977.814'");
-
- //Geo Hash Haversine
- //Can verify here: http://www.movable-type.co.uk/scripts/latlong.html, but
they use a slightly different radius for the earth, so just be close
- //note: using assertJQ because it supports numeric deltas, and by default
too
- assertJQ(req("fl", "*,score", "q", "{!func}ghhsin(" +
DistanceUtils.EARTH_MEAN_RADIUS_KM + ", gh_s1, \"" +
GeohashUtils.encodeLatLon(32, -79) + "\",)", "fq", "id:1"),
- "/response/docs/[0]/score==122.171875");
-
- assertQ(req("fl", "id,point_hash,score", "q", "{!func}recip(ghhsin(" +
DistanceUtils.EARTH_MEAN_RADIUS_KM + ", point_hash, \"" +
GeohashUtils.encodeLatLon(32, -79) + "\"), 1, 1, 0)"),
- "//*[@numFound='7']",
- "//result/doc[1]/str[@name='id'][.='6']",
- "//result/doc[2]/str[@name='id'][.='7']"//all the rest don't matter
- );
-
-
- assertJQ(req("fl", "*,score", "q", "{!func}ghhsin(" +
DistanceUtils.EARTH_MEAN_RADIUS_KM + ", gh_s1, geohash(32, -79))", "fq",
"id:1"),
- "/response/docs/[0]/score==122.171875");
-
}
@Test
public void testLatLon() throws Exception {
- assertU(adoc("id", "100", "store", "1,2"));//copied to store_rpt
+ String sfield = "llp_km"; // primary spatial field
+ double delta = 1e-4;
+
+ // "lat,lon" order
+ assertU(adoc("id", "100", sfield, "1,2", "srpt_geohash_km", "1,2")); //
secondary spatial is equal
assertU(commit());
assertJQ(req("defType","func",
"q","geodist(1,2,3,4)",
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
, "/response/docs/[0]/score==314.40338"
);
@@ -91,7 +75,7 @@ public class DistanceFunctionTest extends SolrTestCaseJ4 {
"q","geodist(1.0,2,3,4.0)",
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
, "/response/docs/[0]/score==314.40338"
);
@@ -101,7 +85,7 @@ public class DistanceFunctionTest extends SolrTestCaseJ4 {
"pt","3,4",
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
, "/response/docs/[0]/score==314.40338"
);
@@ -109,61 +93,61 @@ public class DistanceFunctionTest extends SolrTestCaseJ4 {
assertJQ(req("defType","func",
"q","geodist(1,2)",
"pt","3,4",
- "sfield","store",
+ "sfield", sfield,
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
, "/response/docs/[0]/score==314.40338"
);
// if pt missing, use sfield
- assertJQ(req("defType","func",
+ assertJQ(req("defType","func",
"q","geodist(3,4)",
- "sfield","store",
+ "sfield", sfield,
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
,"/response/docs/[0]/score==314.40338"
);
// if pt missing, use sfield (RPT)
assertJQ(req("defType","func",
"q","geodist(3,4)",
- "sfield","store_rpt",
+ "sfield","srpt_geohash_km",
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
,"/response/docs/[0]/score==314.40338"
);
// read both pt and sfield
- assertJQ(req("defType","func",
+ assertJQ(req("defType","func",
"q","geodist()","pt","3,4",
- "sfield","store",
+ "sfield", sfield,
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
,"/response/docs/[0]/score==314.40338"
);
// read both pt and sfield (RPT)
assertJQ(req("defType","func",
"q","geodist()","pt","3,4",
- "sfield","store_rpt",
+ "sfield","srpt_geohash_km",
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
,"/response/docs/[0]/score==314.40338"
);
// param substitution
assertJQ(req("defType","func",
- "q","geodist($a,$b)",
+ "q","geodist($a)",
"a","3,4",
- "b","store",
+ "sfield", sfield,
"fq","id:100",
"fl","id,score")
- , 1e-5
+ , delta
,"/response/docs/[0]/score==314.40338"
);
diff --git
a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
index 41c093f..40f77c0 100644
---
a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
+++
b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
@@ -370,7 +370,11 @@ public abstract class
AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
@Test
public void testMultivalueLatLonField() throws SolrServerException,
IOException {
- runTestForFieldWithQuery("latLonRemove", new String[] {"1.0,-1.0",
"2.0,-2.0", "3.0,-3.0", "4.0,-4.0"});
+ String[] values = {"1.0,-1.0", "2.0,-2.0", "3.0,-3.0", "4.0,-4.0"};
+ String[] queries = Arrays.stream(values)
+ .map(v -> v.substring(v.indexOf(',') + 1) + " " + v.substring(0,
v.indexOf(','))) // map "lat,lon" to "lon lat"
+ .map(v -> "\"Intersects(BUFFER(POINT(" + v +
"),0.001))\"").toArray(String[]::new);
+ runTestForFieldWithQuery("latLonRemove", values, queries);
}
@Test
diff --git a/solr/solr-ref-guide/src/field-types-included-with-solr.adoc
b/solr/solr-ref-guide/src/field-types-included-with-solr.adoc
index 20bbe1a..74268c0 100644
--- a/solr/solr-ref-guide/src/field-types-included-with-solr.adoc
+++ b/solr/solr-ref-guide/src/field-types-included-with-solr.adoc
@@ -97,8 +97,6 @@ This shortcoming may be addressed in a future release.
|EnumField |Use EnumFieldType instead.
-|LatLonType |Consider using the LatLonPointSpatialField instead. A
single-valued latitude/longitude coordinate pair. Usually it's specified as
"lat,lon" order with a comma. See the section <<spatial-search.adoc#,Spatial
Search>> for more information.
-
|TrieDateField |Use DatePointField instead.
|TrieDoubleField |Use DoublePointField instead.
diff --git a/solr/solr-ref-guide/src/partial-document-updates.adoc
b/solr/solr-ref-guide/src/partial-document-updates.adoc
index ce4a46e..9e601f8 100644
--- a/solr/solr-ref-guide/src/partial-document-updates.adoc
+++ b/solr/solr-ref-guide/src/partial-document-updates.adoc
@@ -74,7 +74,7 @@ If `<copyField/>` destinations are configured as stored, then
Solr will attempt
If such fields contain some information that comes from the indexing program
and some information that comes from copyField, then the information which
originally came from the indexing program will be lost when an atomic update is
made.
There are other kinds of derived fields that must also be set so they aren't
stored.
-Some spatial field types, such as BBoxField and LatLonType, use derived fields.
+Some spatial field types, such as BBoxField and LatLonSpatialFieldType, use
derived fields.
CurrencyFieldType also uses derived fields.
These types create additional fields which are normally specified by a dynamic
field definition.
That dynamic field definition must be not stored, or indexing will fail.
diff --git a/solr/solr-ref-guide/src/spatial-search.adoc
b/solr/solr-ref-guide/src/spatial-search.adoc
index 23c6941..0ca04ba 100644
--- a/solr/solr-ref-guide/src/spatial-search.adoc
+++ b/solr/solr-ref-guide/src/spatial-search.adoc
@@ -28,12 +28,11 @@ Using spatial search, you can:
There are four main field types available for spatial search:
* `LatLonPointSpatialField`
-* `LatLonType` (now deprecated) and its non-geodetic twin `PointType`
+* `PointType`
* `SpatialRecursivePrefixTreeFieldType` (RPT for short), including
`RptWithGeometrySpatialField`, a derivative
* `BBoxField`
`LatLonPointSpatialField` is the ideal field type for the most common
use-cases for lat-lon point data.
-It replaces LatLonType which still exists for backwards compatibility.
RPT offers some more features for more advanced/custom use cases and options
like polygons and heatmaps.
`RptWithGeometrySpatialField` is for indexing and searching non-point data
though it can do points too.
@@ -65,7 +64,7 @@ For PointType however, use `x,y` (a comma).
If you'd rather use a standard industry format, Solr supports
https://en.wikipedia.org/wiki/Well-known_text[WKT] and
http://geojson.org/[GeoJSON].
However it's much bulkier than the raw coordinates for such simple data.
-(Not supported by the deprecated LatLonType or PointType)
+(Not supported by PointType)
=== Indexing GeoJSON and WKT
@@ -128,7 +127,7 @@ A spatial indexed field.
|===
+
If the query is used in a scoring context (e.g., as the main query in `q`),
this _<<local-params.adoc#,local param>>_ determines what scores will be
produced.
-Advanced option; not supported by LatLonType (deprecated) or PointType.
+Advanced option; not supported by PointType.
+
Valid values are:
@@ -160,7 +159,7 @@ When used with `BBoxField`, additional options are
supported:
|===
+
If you only want the query to score (with the above `score` local parameter),
not filter, then set this local parameter to `false`.
-Advanced option; not supported by LatLonType (deprecated) or PointType.
+Advanced option; not supported by PointType.
=== geofilt
@@ -209,8 +208,7 @@ Here's an example:
[source,text]
&q=*:*&fq=store:[45,-94 TO 46,-93]
-LatLonType (deprecated) does *not* support rectangles that cross the dateline.
-For RPT and BBoxField, if you are non-geospatial coordinates (`geo="false"`)
then you must quote the points due to the space, e.g., `"x y"`.
+For RPT and BBoxField, if you don't use lat-lon coordinates (`geo="false"`)
then you must quote the points due to the space, e.g., `"x y"`.
=== Optimizing: Cache or Not
@@ -219,9 +217,7 @@ It's most common to put a spatial query into an "fq"
parameter – a filter quer
By default, Solr will cache the query in the filter cache.
If you know the filter query (be it spatial or not) is fairly unique and not
likely to get a cache hit then specify `cache="false"` as a local-param as seen
in the following example.
-The only spatial types which stand to benefit from this technique are
LatLonPointSpatialField and LatLonType (deprecated).
-Enable docValues on the field (if it isn't already).
-LatLonType (deprecated) additionally requires a `cost="100"` (or more)
local-param.
+The only spatial types which stand to benefit from this technique are those
with docValues like LatLonPointSpatialField or BBoxField.
[source,text]
&q=...mykeywords...&fq=...someotherfilters...&fq={!geofilt
cache=false}&sfield=store&pt=45.15,-93.85&d=5
diff --git
a/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema-sql.xml
b/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema-sql.xml
index 974893c..4f4e616 100644
--- a/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema-sql.xml
+++ b/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema-sql.xml
@@ -378,17 +378,6 @@
<fieldType name="uuid" class="solr.UUIDField"/>
- <!-- Try out some point types -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
- <fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
- <!-- Use the sub field suffix -->
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldtype name="geohash" class="solr.GeoHashField"/>
-
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
-
<!-- some per-field similarity examples -->
<!-- specify a Similarity classname directly -->
@@ -448,21 +437,6 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
- <field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
- <field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
- <field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
-
<!-- test different combinations of indexed and stored -->
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
@@ -578,8 +552,6 @@
<dynamicField name="tv_mv_*" type="text" indexed="true" stored="true"
multiValued="true"
termVectors="true" termPositions="true" termOffsets="true"/>
- <dynamicField name="*_p" type="xyd" indexed="true" stored="true"
multiValued="false"/>
-
<!-- special fields for dynamic copyField test -->
<dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
<dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
diff --git a/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema.xml
b/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema.xml
index 079a35f..727f94a 100644
--- a/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema.xml
+++ b/solr/solrj/src/test-files/solrj/solr/collection1/conf/schema.xml
@@ -353,17 +353,6 @@
<fieldType name="uuid" class="solr.UUIDField"/>
- <!-- Try out some point types -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
- <fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
- <!-- Use the sub field suffix -->
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldType name="geohash" class="solr.GeoHashField"/>
-
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
-
<!-- some per-field similarity examples -->
<!-- specify a Similarity classname directly -->
@@ -416,21 +405,6 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
- <field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
- <field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
- <field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
-
<!-- test different combinations of indexed and stored -->
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
@@ -545,8 +519,6 @@
<dynamicField name="tv_mv_*" type="text" indexed="true" stored="true"
multiValued="true"
termVectors="true" termPositions="true" termOffsets="true"/>
- <dynamicField name="*_p" type="xyd" indexed="true" stored="true"
multiValued="false"/>
-
<!-- special fields for dynamic copyField test -->
<dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
<dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
diff --git
a/solr/solrj/src/test-files/solrj/solr/configsets/streaming/conf/schema.xml
b/solr/solrj/src/test-files/solrj/solr/configsets/streaming/conf/schema.xml
index 6cd4f91..42b1e70 100644
--- a/solr/solrj/src/test-files/solrj/solr/configsets/streaming/conf/schema.xml
+++ b/solr/solrj/src/test-files/solrj/solr/configsets/streaming/conf/schema.xml
@@ -355,18 +355,10 @@
<fieldType name="uuid" class="solr.UUIDField" />
- <!-- Try out some point types -->
- <fieldType name="xy" class="solr.PointType" dimension="2"
subFieldType="double"/>
- <fieldType name="x" class="solr.PointType" dimension="1"
subFieldType="double"/>
- <fieldType name="tenD" class="solr.PointType" dimension="10"
subFieldType="double"/>
- <!-- Use the sub field suffix -->
- <fieldType name="xyd" class="solr.PointType" dimension="2"
subFieldSuffix="_d1"/>
- <fieldtype name="geohash" class="solr.GeoHashField"/>
+ <!-- A specialized field for geospatial search filters and distance
sorting. -->
+ <fieldType name="location" class="solr.LatLonPointSpatialField"
docValues="true"/>
-
- <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
-
- <!-- some per-field similarity examples -->
+ <!-- some per-field similarity examples -->
<!-- specify a Similarity classname directly -->
<!--
@@ -436,21 +428,6 @@
<field name="shouldbestored" type="unstored" stored="true"/>
<field name="shouldbeunindexed" type="unstored" indexed="false"
stored="true"/>
- <!-- Test points -->
- <!-- Test points -->
- <field name="home" type="xy" indexed="true" stored="true"
multiValued="false"/>
- <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
- <field name="homed" type="xyd" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_ns" type="xy" indexed="true" stored="false"
multiValued="false"/>
- <field name="work" type="xy" indexed="true" stored="true"
multiValued="false"/>
-
- <field name="home_ll" type="latLon" indexed="true" stored="true"
multiValued="false"/>
- <field name="home_gh" type="geohash" indexed="true" stored="true"
multiValued="false"/>
-
-
- <field name="point10" type="tenD" indexed="true" stored="true"
multiValued="false"/>
-
-
<!-- test different combinations of indexed and stored -->
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
@@ -570,7 +547,7 @@
<dynamicField name="tv_mv_*" type="text" indexed="true" stored="true"
multiValued="true"
termVectors="true" termPositions="true" termOffsets="true"/>
- <dynamicField name="*_p" type="xyd" indexed="true" stored="true"
multiValued="false"/>
+ <dynamicField name="*_p" type="location" indexed="true" stored="true"
multiValued="false"/>
<!-- special fields for dynamic copyField test -->
<dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>