add smart name filter wrapping for geo filters to automatically filter by type if as well if provided
This commit is contained in:
parent
832914bf6d
commit
097071a9d2
|
@ -33,6 +33,9 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The "fquery" filter is the same as the {@link QueryFilterParser} except that it allows also to
|
||||||
|
* associate a name with the query filter.
|
||||||
|
*
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class FQueryFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
public class FQueryFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||||
|
|
|
@ -35,6 +35,8 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
|
@ -148,6 +150,7 @@ public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implement
|
||||||
}
|
}
|
||||||
|
|
||||||
MapperService mapperService = parseContext.mapperService();
|
MapperService mapperService = parseContext.mapperService();
|
||||||
|
|
||||||
FieldMapper mapper = mapperService.smartNameFieldMapper(latFieldName);
|
FieldMapper mapper = mapperService.smartNameFieldMapper(latFieldName);
|
||||||
if (mapper == null) {
|
if (mapper == null) {
|
||||||
throw new QueryParsingException(index, "failed to find lat field [" + latFieldName + "]");
|
throw new QueryParsingException(index, "failed to find lat field [" + latFieldName + "]");
|
||||||
|
@ -161,7 +164,8 @@ public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implement
|
||||||
lonFieldName = mapper.names().indexName();
|
lonFieldName = mapper.names().indexName();
|
||||||
|
|
||||||
|
|
||||||
GeoBoundingBoxFilter filter = new GeoBoundingBoxFilter(topLeft, bottomRight, latFieldName, lonFieldName, mapper.fieldDataType(), parseContext.indexCache().fieldData());
|
Filter filter = new GeoBoundingBoxFilter(topLeft, bottomRight, latFieldName, lonFieldName, mapper.fieldDataType(), parseContext.indexCache().fieldData());
|
||||||
|
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(latFieldName), parseContext);
|
||||||
if (filterName != null) {
|
if (filterName != null) {
|
||||||
parseContext.addNamedFilter(filterName, filter);
|
parseContext.addNamedFilter(filterName, filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
|
@ -167,7 +169,8 @@ public class GeoDistanceFilterParser extends AbstractIndexComponent implements X
|
||||||
}
|
}
|
||||||
lonFieldName = mapper.names().indexName();
|
lonFieldName = mapper.names().indexName();
|
||||||
|
|
||||||
GeoDistanceFilter filter = new GeoDistanceFilter(lat, lon, distance, geoDistance, latFieldName, lonFieldName, mapper.fieldDataType(), parseContext.indexCache().fieldData());
|
Filter filter = new GeoDistanceFilter(lat, lon, distance, geoDistance, latFieldName, lonFieldName, mapper.fieldDataType(), parseContext.indexCache().fieldData());
|
||||||
|
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(latFieldName), parseContext);
|
||||||
if (filterName != null) {
|
if (filterName != null) {
|
||||||
parseContext.addNamedFilter(filterName, filter);
|
parseContext.addNamedFilter(filterName, filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
|
@ -160,7 +162,8 @@ public class GeoPolygonFilterParser extends AbstractIndexComponent implements XC
|
||||||
}
|
}
|
||||||
lonFieldName = mapper.names().indexName();
|
lonFieldName = mapper.names().indexName();
|
||||||
|
|
||||||
GeoPolygonFilter filter = new GeoPolygonFilter(points.toArray(new GeoPolygonFilter.Point[points.size()]), latFieldName, lonFieldName, mapper.fieldDataType(), parseContext.indexCache().fieldData());
|
Filter filter = new GeoPolygonFilter(points.toArray(new GeoPolygonFilter.Point[points.size()]), latFieldName, lonFieldName, mapper.fieldDataType(), parseContext.indexCache().fieldData());
|
||||||
|
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(latFieldName), parseContext);
|
||||||
if (filterName != null) {
|
if (filterName != null) {
|
||||||
parseContext.addNamedFilter(filterName, filter);
|
parseContext.addNamedFilter(filterName, filter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue