Adressing review comments
This commit is contained in:
parent
1908d6dc73
commit
d9de129995
|
@ -255,22 +255,15 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> implements S
|
||||||
throw new QueryShardException(context, "Sorting not supported for field[" + fieldName + "]");
|
throw new QueryShardException(context, "Sorting not supported for field[" + fieldName + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable when we also know how to detect fields that do tokenize, but only emit one token
|
|
||||||
/*if (fieldMapper instanceof StringFieldMapper) {
|
|
||||||
StringFieldMapper stringFieldMapper = (StringFieldMapper) fieldMapper;
|
|
||||||
if (stringFieldMapper.fieldType().tokenized()) {
|
|
||||||
// Fail early
|
|
||||||
throw new SearchParseException(context, "Can't sort on tokenized string field[" + fieldName + "]");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
MultiValueMode localSortMode = null;
|
MultiValueMode localSortMode = null;
|
||||||
if (sortMode != null) {
|
if (sortMode != null) {
|
||||||
localSortMode = MultiValueMode.fromString(sortMode.toString());
|
localSortMode = MultiValueMode.fromString(sortMode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldType.isNumeric() == false && (sortMode == SortMode.SUM || sortMode == SortMode.AVG)) {
|
if (fieldType.isNumeric() == false && (sortMode == SortMode.SUM || sortMode == SortMode.AVG)) {
|
||||||
throw new QueryShardException(context, "we only support AVG and SUM on number based fields");
|
throw new QueryShardException(context, "we only support AVG and SUM on number based fields");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean reverse = (order == SortOrder.DESC);
|
boolean reverse = (order == SortOrder.DESC);
|
||||||
if (localSortMode == null) {
|
if (localSortMode == null) {
|
||||||
localSortMode = reverse ? MultiValueMode.MAX : MultiValueMode.MIN;
|
localSortMode = reverse ? MultiValueMode.MAX : MultiValueMode.MIN;
|
||||||
|
|
|
@ -488,10 +488,10 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
|
||||||
|
|
||||||
if (!indexCreatedBeforeV2_0 && !ignoreMalformed) {
|
if (!indexCreatedBeforeV2_0 && !ignoreMalformed) {
|
||||||
for (GeoPoint point : localPoints) {
|
for (GeoPoint point : localPoints) {
|
||||||
if (point.lat() > 90.0 || point.lat() < -90.0) {
|
if (GeoUtils.isValidLatitude(point.lat()) == false) {
|
||||||
throw new ElasticsearchParseException("illegal latitude value [{}] for [GeoDistanceSort]", point.lat());
|
throw new ElasticsearchParseException("illegal latitude value [{}] for [GeoDistanceSort]", point.lat());
|
||||||
}
|
}
|
||||||
if (point.lon() > 180.0 || point.lon() < -180) {
|
if (GeoUtils.isValidLongitude(point.lon()) == false) {
|
||||||
throw new ElasticsearchParseException("illegal longitude value [{}] for [GeoDistanceSort]", point.lon());
|
throw new ElasticsearchParseException("illegal longitude value [{}] for [GeoDistanceSort]", point.lon());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,6 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
final Nested nested = resolveNested(context, nestedPath, nestedFilter);
|
final Nested nested = resolveNested(context, nestedPath, nestedFilter);
|
||||||
|
|
||||||
final IndexFieldData.XFieldComparatorSource fieldComparatorSource;
|
final IndexFieldData.XFieldComparatorSource fieldComparatorSource;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case STRING:
|
case STRING:
|
||||||
|
|
|
@ -217,15 +217,6 @@ public class SortParseElement implements SearchParseElement {
|
||||||
throw new QueryShardException(context, "Sorting not supported for field[" + fieldName + "]");
|
throw new QueryShardException(context, "Sorting not supported for field[" + fieldName + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable when we also know how to detect fields that do tokenize, but only emit one token
|
|
||||||
/*if (fieldMapper instanceof StringFieldMapper) {
|
|
||||||
StringFieldMapper stringFieldMapper = (StringFieldMapper) fieldMapper;
|
|
||||||
if (stringFieldMapper.fieldType().tokenized()) {
|
|
||||||
// Fail early
|
|
||||||
throw new SearchParseException(context, "Can't sort on tokenized string field[" + fieldName + "]");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// We only support AVG and SUM on number based fields
|
// We only support AVG and SUM on number based fields
|
||||||
if (fieldType.isNumeric() == false && (sortMode == MultiValueMode.SUM || sortMode == MultiValueMode.AVG)) {
|
if (fieldType.isNumeric() == false && (sortMode == MultiValueMode.SUM || sortMode == MultiValueMode.AVG)) {
|
||||||
sortMode = null;
|
sortMode = null;
|
||||||
|
|
Loading…
Reference in New Issue