|
|
@@ -19,6 +19,7 @@ import org.apache.lucene.search.comparators.DoubleComparator;
|
|
|
import org.apache.lucene.util.BitSet;
|
|
|
import org.elasticsearch.ElasticsearchParseException;
|
|
|
import org.elasticsearch.Version;
|
|
|
+import org.elasticsearch.common.logging.DeprecationLogger;
|
|
|
import org.elasticsearch.common.xcontent.ParseField;
|
|
|
import org.elasticsearch.common.ParsingException;
|
|
|
import org.elasticsearch.common.geo.GeoDistance;
|
|
|
@@ -31,6 +32,7 @@ import org.elasticsearch.common.util.BigArrays;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.common.xcontent.XContentParser;
|
|
|
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
|
|
+import org.elasticsearch.core.RestApiVersion;
|
|
|
import org.elasticsearch.index.fielddata.FieldData;
|
|
|
import org.elasticsearch.index.fielddata.IndexFieldData;
|
|
|
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
|
|
@@ -63,6 +65,7 @@ import static org.elasticsearch.search.sort.NestedSortBuilder.NESTED_FIELD;
|
|
|
* A geo distance based sorting on a geo point like field.
|
|
|
*/
|
|
|
public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder> {
|
|
|
+ private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(GeoDistanceSortBuilder.class);
|
|
|
|
|
|
public static final String NAME = "_geo_distance";
|
|
|
public static final String ALTERNATIVE_NAME = "_geoDistance";
|
|
|
@@ -406,7 +409,15 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
|
|
|
|
|
|
fieldName = currentName;
|
|
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
|
|
- if (NESTED_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
+ if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
|
|
|
+ NESTED_FILTER_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
+ deprecationLogger.compatibleApiWarning("nested_filter",
|
|
|
+ "[nested_filter] has been removed in favour of the [nested] parameter");
|
|
|
+ throw new ParsingException(
|
|
|
+ parser.getTokenLocation(),
|
|
|
+ "[nested_filter] has been removed in favour of the [nested] parameter",
|
|
|
+ currentName);
|
|
|
+ } else if (NESTED_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
nestedSort = NestedSortBuilder.fromXContent(parser);
|
|
|
} else {
|
|
|
// the json in the format of -> field : { lat : 30, lon : 12 }
|
|
|
@@ -423,7 +434,15 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
|
|
|
geoPoints.add(point);
|
|
|
}
|
|
|
} else if (token.isValue()) {
|
|
|
- if (ORDER_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
+ if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
|
|
|
+ NESTED_PATH_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
+ deprecationLogger.compatibleApiWarning("nested_path",
|
|
|
+ "[nested_path] has been removed in favour of the [nested] parameter");
|
|
|
+ throw new ParsingException(
|
|
|
+ parser.getTokenLocation(),
|
|
|
+ "[nested_path] has been removed in favour of the [nested] parameter",
|
|
|
+ currentName);
|
|
|
+ } else if (ORDER_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
order = SortOrder.fromString(parser.text());
|
|
|
} else if (UNIT_FIELD.match(currentName, parser.getDeprecationHandler())) {
|
|
|
unit = DistanceUnit.fromString(parser.text());
|
|
|
@@ -435,24 +454,24 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
|
|
|
sortMode = SortMode.fromString(parser.text());
|
|
|
} else if (IGNORE_UNMAPPED.match(currentName, parser.getDeprecationHandler())) {
|
|
|
ignoreUnmapped = parser.booleanValue();
|
|
|
- } else if (token == Token.VALUE_STRING){
|
|
|
+ } else if (token == Token.VALUE_STRING) {
|
|
|
if (fieldName != null && fieldName.equals(currentName) == false) {
|
|
|
throw new ParsingException(
|
|
|
- parser.getTokenLocation(),
|
|
|
- "Trying to reset fieldName to [{}], already set to [{}].",
|
|
|
- currentName,
|
|
|
- fieldName);
|
|
|
+ parser.getTokenLocation(),
|
|
|
+ "Trying to reset fieldName to [{}], already set to [{}].",
|
|
|
+ currentName,
|
|
|
+ fieldName);
|
|
|
}
|
|
|
|
|
|
GeoPoint point = new GeoPoint();
|
|
|
point.resetFromString(parser.text());
|
|
|
geoPoints.add(point);
|
|
|
fieldName = currentName;
|
|
|
- } else if (fieldName.equals(currentName)){
|
|
|
+ } else if (fieldName.equals(currentName)) {
|
|
|
throw new ParsingException(
|
|
|
- parser.getTokenLocation(),
|
|
|
- "Only geohashes of type string supported for field [{}]",
|
|
|
- currentName);
|
|
|
+ parser.getTokenLocation(),
|
|
|
+ "Only geohashes of type string supported for field [{}]",
|
|
|
+ currentName);
|
|
|
} else {
|
|
|
throw new ParsingException(
|
|
|
parser.getTokenLocation(),
|