When searching against an index/type, use the type information to derive different search aspects, closes #1391.

This commit is contained in:
Shay Banon 2011-10-18 00:38:28 +02:00
parent 325064c7aa
commit 6a146e7ad0
78 changed files with 499 additions and 400 deletions

View File

@ -19,6 +19,7 @@
package org.apache.lucene.queryParser;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.index.Term;
@ -30,7 +31,6 @@ import org.elasticsearch.common.io.FastStringReader;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.FieldMappers;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
import org.elasticsearch.index.query.QueryParseContext;
@ -115,9 +115,11 @@ public class MapperQueryParser extends QueryParser {
return fieldQueryExtension.query(parseContext, queryText);
}
currentMapper = null;
if (parseContext.mapperService() != null) {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.mapperService().smartName(field);
Analyzer oldAnalyzer = analyzer;
try {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field);
if (fieldMappers != null) {
analyzer = fieldMappers.searchAnalyzer();
currentMapper = fieldMappers.fieldMappers().mapper();
if (currentMapper != null) {
Query query = null;
@ -130,8 +132,10 @@ public class MapperQueryParser extends QueryParser {
return wrapSmartNameQuery(query, fieldMappers, parseContext);
}
}
}
return super.getFieldQuery(field, queryText, quoted);
} finally {
analyzer = oldAnalyzer;
}
}
@Override protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException {
@ -142,8 +146,7 @@ public class MapperQueryParser extends QueryParser {
part2 = null;
}
currentMapper = null;
if (parseContext.mapperService() != null) {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.mapperService().smartName(field);
MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field);
if (fieldMappers != null) {
currentMapper = fieldMappers.fieldMappers().mapper();
if (currentMapper != null) {
@ -151,14 +154,12 @@ public class MapperQueryParser extends QueryParser {
return wrapSmartNameQuery(rangeQuery, fieldMappers, parseContext);
}
}
}
return newRangeQuery(field, part1, part2, inclusive);
}
@Override protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException {
currentMapper = null;
if (parseContext.mapperService() != null) {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.mapperService().smartName(field);
MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field);
if (fieldMappers != null) {
currentMapper = fieldMappers.fieldMappers().mapper();
if (currentMapper != null) {
@ -166,24 +167,27 @@ public class MapperQueryParser extends QueryParser {
return wrapSmartNameQuery(fuzzyQuery, fieldMappers, parseContext);
}
}
}
return super.getFuzzyQuery(field, termStr, minSimilarity);
}
@Override protected Query getPrefixQuery(String field, String termStr) throws ParseException {
String indexedNameField = field;
currentMapper = null;
if (parseContext.mapperService() != null) {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.mapperService().smartName(field);
Analyzer oldAnalyzer = analyzer;
try {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field);
if (fieldMappers != null) {
analyzer = fieldMappers.searchAnalyzer();
currentMapper = fieldMappers.fieldMappers().mapper();
if (currentMapper != null) {
indexedNameField = currentMapper.names().indexName();
}
return wrapSmartNameQuery(getPossiblyAnalyzedPrefixQuery(indexedNameField, termStr), fieldMappers, parseContext);
}
}
return getPossiblyAnalyzedPrefixQuery(indexedNameField, termStr);
} finally {
analyzer = oldAnalyzer;
}
}
private Query getPossiblyAnalyzedPrefixQuery(String field, String termStr) throws ParseException {
@ -234,17 +238,21 @@ public class MapperQueryParser extends QueryParser {
}
String indexedNameField = field;
currentMapper = null;
if (parseContext.mapperService() != null) {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.mapperService().smartName(field);
Analyzer oldAnalyzer = analyzer;
try {
MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field);
if (fieldMappers != null) {
analyzer = fieldMappers.searchAnalyzer();
currentMapper = fieldMappers.fieldMappers().mapper();
if (currentMapper != null) {
indexedNameField = currentMapper.names().indexName();
}
return wrapSmartNameQuery(getPossiblyAnalyzedWildcardQuery(indexedNameField, termStr), fieldMappers, parseContext);
}
}
return getPossiblyAnalyzedWildcardQuery(indexedNameField, termStr);
} finally {
analyzer = oldAnalyzer;
}
}
private Query getPossiblyAnalyzedWildcardQuery(String field, String termStr) throws ParseException {
@ -318,15 +326,4 @@ public class MapperQueryParser extends QueryParser {
}
return optimizeQuery(fixNegativeQueryIfNeeded(q));
}
protected FieldMapper fieldMapper(String smartName) {
if (parseContext.mapperService() == null) {
return null;
}
FieldMappers fieldMappers = parseContext.mapperService().smartNameFieldMappers(smartName);
if (fieldMappers == null) {
return null;
}
return fieldMappers.mapper();
}
}

View File

@ -408,38 +408,6 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
return objectMappers.get(path);
}
public SmartNameObjectMapper smartNameObjectMapper(String smartName) {
int dotIndex = smartName.indexOf('.');
if (dotIndex != -1) {
String possibleType = smartName.substring(0, dotIndex);
DocumentMapper possibleDocMapper = mappers.get(possibleType);
if (possibleDocMapper != null) {
String possiblePath = smartName.substring(dotIndex + 1);
ObjectMapper mapper = possibleDocMapper.objectMappers().get(possiblePath);
if (mapper != null) {
return new SmartNameObjectMapper(mapper, possibleDocMapper);
}
}
}
ObjectMappers mappers = objectMapper(smartName);
if (mappers != null) {
return new SmartNameObjectMapper(mappers.mapper(), null);
}
return null;
}
/**
* Same as {@link #smartNameFieldMappers(String)} but returns the first field mapper for it. Returns
* <tt>null</tt> if there is none.
*/
public FieldMapper smartNameFieldMapper(String smartName) {
FieldMappers fieldMappers = smartNameFieldMappers(smartName);
if (fieldMappers != null) {
return fieldMappers.mapper();
}
return null;
}
public Set<String> simpleMatchToIndexNames(String pattern) {
int dotIndex = pattern.indexOf('.');
if (dotIndex != -1) {
@ -478,6 +446,79 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
return fields;
}
public SmartNameObjectMapper smartNameObjectMapper(String smartName) {
int dotIndex = smartName.indexOf('.');
if (dotIndex != -1) {
String possibleType = smartName.substring(0, dotIndex);
DocumentMapper possibleDocMapper = mappers.get(possibleType);
if (possibleDocMapper != null) {
String possiblePath = smartName.substring(dotIndex + 1);
ObjectMapper mapper = possibleDocMapper.objectMappers().get(possiblePath);
if (mapper != null) {
return new SmartNameObjectMapper(mapper, possibleDocMapper);
}
}
}
ObjectMappers mappers = objectMapper(smartName);
if (mappers != null) {
return new SmartNameObjectMapper(mappers.mapper(), null);
}
return null;
}
/**
* Same as {@link #smartNameFieldMappers(String)} but returns the first field mapper for it. Returns
* <tt>null</tt> if there is none.
*/
public FieldMapper smartNameFieldMapper(String smartName) {
FieldMappers fieldMappers = smartNameFieldMappers(smartName);
if (fieldMappers != null) {
return fieldMappers.mapper();
}
return null;
}
public FieldMapper smartNameFieldMapper(String smartName, @Nullable String[] types) {
FieldMappers fieldMappers = smartNameFieldMappers(smartName, types);
if (fieldMappers != null) {
return fieldMappers.mapper();
}
return null;
}
public FieldMappers smartNameFieldMappers(String smartName, @Nullable String[] types) {
if (types == null || types.length == 0) {
return smartNameFieldMappers(smartName);
}
for (String type : types) {
DocumentMapper documentMapper = mappers.get(type);
// we found a mapper
if (documentMapper != null) {
// see if we find a field for it
FieldMappers mappers = documentMapper.mappers().smartName(smartName);
if (mappers != null) {
return mappers;
}
}
}
// did not find explicit field in the type provided, see if its prefixed with type
int dotIndex = smartName.indexOf('.');
if (dotIndex != -1) {
String possibleType = smartName.substring(0, dotIndex);
DocumentMapper possibleDocMapper = mappers.get(possibleType);
if (possibleDocMapper != null) {
String possibleName = smartName.substring(dotIndex + 1);
FieldMappers mappers = possibleDocMapper.mappers().smartName(possibleName);
if (mappers != null) {
return mappers;
}
}
}
// we did not find the field mapping in any of the types, so don't go and try to find
// it in other types...
return null;
}
/**
* Same as {@link #smartName(String)}, except it returns just the field mappers.
*/
@ -505,6 +546,39 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
return name(smartName);
}
public SmartNameFieldMappers smartName(String smartName, @Nullable String[] types) {
if (types == null || types.length == 0) {
return smartName(smartName);
}
for (String type : types) {
DocumentMapper documentMapper = mappers.get(type);
// we found a mapper
if (documentMapper != null) {
// see if we find a field for it
FieldMappers mappers = documentMapper.mappers().smartName(smartName);
if (mappers != null) {
return new SmartNameFieldMappers(this, mappers, documentMapper, false);
}
}
}
// did not find explicit field in the type provided, see if its prefixed with type
int dotIndex = smartName.indexOf('.');
if (dotIndex != -1) {
String possibleType = smartName.substring(0, dotIndex);
DocumentMapper possibleDocMapper = mappers.get(possibleType);
if (possibleDocMapper != null) {
String possibleName = smartName.substring(dotIndex + 1);
FieldMappers mappers = possibleDocMapper.mappers().smartName(possibleName);
if (mappers != null) {
return new SmartNameFieldMappers(this, mappers, possibleDocMapper, true);
}
}
}
// we did not find the field mapping in any of the types, so don't go and try to find
// it in other types...
return null;
}
/**
* Returns smart field mappers based on a smart name. A smart name is one that can optioannly be prefixed
* with a type (and then a '.'). If it is, then the {@link MapperService.SmartNameFieldMappers}
@ -526,21 +600,21 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
String possibleName = smartName.substring(dotIndex + 1);
FieldMappers mappers = possibleDocMapper.mappers().smartName(possibleName);
if (mappers != null) {
return new SmartNameFieldMappers(mappers, possibleDocMapper);
return new SmartNameFieldMappers(this, mappers, possibleDocMapper, true);
}
}
}
FieldMappers fieldMappers = fullName(smartName);
if (fieldMappers != null) {
return new SmartNameFieldMappers(fieldMappers, null);
return new SmartNameFieldMappers(this, fieldMappers, null, false);
}
fieldMappers = indexName(smartName);
if (fieldMappers != null) {
return new SmartNameFieldMappers(fieldMappers, null);
return new SmartNameFieldMappers(this, fieldMappers, null, false);
}
fieldMappers = name(smartName);
if (fieldMappers != null) {
return new SmartNameFieldMappers(fieldMappers, null);
return new SmartNameFieldMappers(this, fieldMappers, null, false);
}
return null;
}
@ -576,12 +650,16 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
}
public static class SmartNameFieldMappers {
private final MapperService mapperService;
private final FieldMappers fieldMappers;
private final DocumentMapper docMapper;
private final boolean explicitTypeInName;
public SmartNameFieldMappers(FieldMappers fieldMappers, @Nullable DocumentMapper docMapper) {
public SmartNameFieldMappers(MapperService mapperService, FieldMappers fieldMappers, @Nullable DocumentMapper docMapper, boolean explicitTypeInName) {
this.mapperService = mapperService;
this.fieldMappers = fieldMappers;
this.docMapper = docMapper;
this.explicitTypeInName = explicitTypeInName;
}
/**
@ -620,6 +698,29 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
public DocumentMapper docMapper() {
return docMapper;
}
/**
* Returns <tt>true</tt> if the type is explicitly specified in the name.
*/
public boolean explicitTypeInName() {
return this.explicitTypeInName;
}
/**
* The best effort search analyzer associated with this field.
*/
public Analyzer searchAnalyzer() {
if (hasMapper()) {
Analyzer analyzer = mapper().searchAnalyzer();
if (analyzer != null) {
return analyzer;
}
}
if (docMapper != null && docMapper.searchAnalyzer() != null) {
return docMapper.searchAnalyzer();
}
return mapperService.searchAnalyzer();
}
}
final class SmartIndexNameSearchAnalyzer extends Analyzer {

View File

@ -79,7 +79,7 @@ public class FieldMaskingSpanQueryParser implements QueryParser {
throw new QueryParsingException(parseContext.index(), "field_masking_span must have [field] set for it");
}
FieldMapper mapper = parseContext.mapperService().smartNameFieldMapper(field);
FieldMapper mapper = parseContext.fieldMapper(field);
if (mapper != null) {
field = mapper.names().indexName();
}

View File

@ -169,12 +169,11 @@ public class GeoBoundingBoxFilterParser implements FilterParser {
bottomRight.lon = GeoUtils.normalizeLon(bottomRight.lon);
}
MapperService mapperService = parseContext.mapperService();
FieldMapper mapper = mapperService.smartNameFieldMapper(fieldName);
if (mapper == null) {
MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new QueryParsingException(parseContext.index(), "failed to find geo_point field [" + fieldName + "]");
}
FieldMapper mapper = smartMappers.mapper();
if (!(mapper instanceof GeoPointFieldMapper.GeoStringFieldMapper)) {
throw new QueryParsingException(parseContext.index(), "field [" + fieldName + "] is not a geo_point field");
}
@ -194,7 +193,7 @@ public class GeoBoundingBoxFilterParser implements FilterParser {
if (cache) {
filter = parseContext.cacheFilter(filter, cacheKey);
}
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(fieldName), parseContext);
filter = wrapSmartNameFilter(filter, smartMappers, parseContext);
if (filterName != null) {
parseContext.addNamedFilter(filterName, filter);
}

View File

@ -172,11 +172,11 @@ public class GeoDistanceFilterParser implements FilterParser {
lon = GeoUtils.normalizeLon(lon);
}
MapperService mapperService = parseContext.mapperService();
FieldMapper mapper = mapperService.smartNameFieldMapper(fieldName);
if (mapper == null) {
MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new QueryParsingException(parseContext.index(), "failed to find geo_point field [" + fieldName + "]");
}
FieldMapper mapper = smartMappers.mapper();
if (mapper.fieldDataType() != GeoPointFieldDataType.TYPE) {
throw new QueryParsingException(parseContext.index(), "field [" + fieldName + "] is not a geo_point field");
}
@ -187,7 +187,7 @@ public class GeoDistanceFilterParser implements FilterParser {
if (cache) {
filter = parseContext.cacheFilter(filter, cacheKey);
}
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(fieldName), parseContext);
filter = wrapSmartNameFilter(filter, smartMappers, parseContext);
if (filterName != null) {
parseContext.addNamedFilter(filterName, filter);
}

View File

@ -229,11 +229,11 @@ public class GeoDistanceRangeFilterParser implements FilterParser {
lon = GeoUtils.normalizeLon(lon);
}
MapperService mapperService = parseContext.mapperService();
FieldMapper mapper = mapperService.smartNameFieldMapper(fieldName);
if (mapper == null) {
MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new QueryParsingException(parseContext.index(), "failed to find geo_point field [" + fieldName + "]");
}
FieldMapper mapper = smartMappers.mapper();
if (mapper.fieldDataType() != GeoPointFieldDataType.TYPE) {
throw new QueryParsingException(parseContext.index(), "field [" + fieldName + "] is not a geo_point field");
}
@ -244,7 +244,7 @@ public class GeoDistanceRangeFilterParser implements FilterParser {
if (cache) {
filter = parseContext.cacheFilter(filter, cacheKey);
}
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(fieldName), parseContext);
filter = wrapSmartNameFilter(filter, smartMappers, parseContext);
if (filterName != null) {
parseContext.addNamedFilter(filterName, filter);
}

View File

@ -165,11 +165,11 @@ public class GeoPolygonFilterParser implements FilterParser {
}
}
MapperService mapperService = parseContext.mapperService();
FieldMapper mapper = mapperService.smartNameFieldMapper(fieldName);
if (mapper == null) {
MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new QueryParsingException(parseContext.index(), "failed to find geo_point field [" + fieldName + "]");
}
FieldMapper mapper = smartMappers.mapper();
if (mapper.fieldDataType() != GeoPointFieldDataType.TYPE) {
throw new QueryParsingException(parseContext.index(), "field [" + fieldName + "] is not a geo_point field");
}
@ -179,7 +179,7 @@ public class GeoPolygonFilterParser implements FilterParser {
if (cache) {
filter = parseContext.cacheFilter(filter, cacheKey);
}
filter = wrapSmartNameFilter(filter, parseContext.smartFieldMappers(fieldName), parseContext);
filter = wrapSmartNameFilter(filter, smartMappers, parseContext);
if (filterName != null) {
parseContext.addNamedFilter(filterName, filter);
}

View File

@ -113,9 +113,9 @@ public class MoreLikeThisFieldQueryParser implements QueryParser {
if (smartNameFieldMappers != null) {
if (smartNameFieldMappers.hasMapper()) {
fieldName = smartNameFieldMappers.mapper().names().indexName();
if (analyzer == null) {
analyzer = smartNameFieldMappers.mapper().searchAnalyzer();
}
if (analyzer == null) {
analyzer = smartNameFieldMappers.searchAnalyzer();
}
}
if (analyzer == null) {

View File

@ -40,6 +40,7 @@ import org.elasticsearch.index.mapper.FieldMappers;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
import java.util.Map;
@ -202,7 +203,8 @@ public class QueryParseContext {
}
public FieldMapper fieldMapper(String name) {
FieldMappers fieldMappers = indexQueryParser.mapperService.smartNameFieldMappers(name);
SearchContext searchContext = SearchContext.current();
FieldMappers fieldMappers = indexQueryParser.mapperService.smartNameFieldMappers(name, searchContext == null ? null : searchContext.types());
if (fieldMappers == null) {
return null;
}
@ -218,6 +220,7 @@ public class QueryParseContext {
}
public MapperService.SmartNameFieldMappers smartFieldMappers(String name) {
return indexQueryParser.mapperService.smartName(name);
SearchContext searchContext = SearchContext.current();
return indexQueryParser.mapperService.smartName(name, searchContext == null ? null : searchContext.types());
}
}

View File

@ -83,7 +83,7 @@ public final class QueryParsers {
if (smartFieldMappers == null) {
return query;
}
if (!smartFieldMappers.hasDocMapper()) {
if (!smartFieldMappers.hasDocMapper() || !smartFieldMappers.explicitTypeInName()) {
return query;
}
DocumentMapper docMapper = smartFieldMappers.docMapper();
@ -95,7 +95,7 @@ public final class QueryParsers {
if (smartFieldMappers == null) {
return filter;
}
if (!smartFieldMappers.hasDocMapper()) {
if (!smartFieldMappers.hasDocMapper() || !smartFieldMappers.explicitTypeInName()) {
return filter;
}
DocumentMapper docMapper = smartFieldMappers.docMapper();

View File

@ -130,8 +130,8 @@ public class TextQueryParser {
if (mapper != null) {
analyzer = mapper.searchAnalyzer();
}
if (analyzer == null && smartNameFieldMappers != null && smartNameFieldMappers.docMapper() != null) {
analyzer = smartNameFieldMappers.docMapper().searchAnalyzer();
if (analyzer == null && smartNameFieldMappers != null) {
analyzer = smartNameFieldMappers.searchAnalyzer();
}
if (analyzer == null) {
analyzer = parseContext.mapperService().searchAnalyzer();

View File

@ -63,13 +63,13 @@ public class CountDateHistogramFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -152,7 +152,7 @@ public class DateHistogramFacetProcessor extends AbstractComponent implements Fa
throw new FacetPhaseExecutionException(facetName, "key field is required to be set for histogram facet, either using [field] or using [key_field]");
}
FieldMapper mapper = context.mapperService().smartNameFieldMapper(keyField);
FieldMapper mapper = context.smartNameFieldMapper(keyField);
if (mapper == null) {
throw new FacetPhaseExecutionException(facetName, "(key) field [" + keyField + "] not found");
}

View File

@ -67,20 +67,20 @@ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + keyFieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
keyIndexFieldName = smartMappers.mapper().names().indexName();
keyFieldDataType = smartMappers.mapper().fieldDataType();
FieldMapper mapper = context.mapperService().smartNameFieldMapper(valueFieldName);
FieldMapper mapper = context.smartNameFieldMapper(valueFieldName);
if (mapper == null) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for value_field [" + valueFieldName + "]");
}

View File

@ -68,13 +68,13 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -69,7 +69,7 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector {
this.fixedSourceDistance = geoDistance.fixedSourceDistance(lat, lon, unit);
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
@ -78,7 +78,7 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.geo.GeoPointFieldData;
import org.elasticsearch.index.search.geo.GeoDistance;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -44,12 +44,12 @@ public class ValueGeoDistanceFacetCollector extends GeoDistanceFacetCollector {
GeoDistanceFacet.Entry[] entries, SearchContext context, String valueFieldName) {
super(facetName, fieldName, lat, lon, unit, geoDistance, entries, context);
FieldMapper mapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (mapper == null) {
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + valueFieldName + "]");
}
this.indexValueFieldName = valueFieldName;
this.valueFieldDataType = mapper.fieldDataType();
this.indexValueFieldName = smartMappers.mapper().names().indexName();
this.valueFieldDataType = smartMappers.mapper().fieldDataType();
this.aggregator = new Aggregator(fixedSourceDistance, entries);
}

View File

@ -32,7 +32,11 @@ import org.elasticsearch.search.facet.FacetProcessor;
import org.elasticsearch.search.facet.histogram.bounded.BoundedCountHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.bounded.BoundedValueHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.bounded.BoundedValueScriptHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.unbounded.*;
import org.elasticsearch.search.facet.histogram.unbounded.CountHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.unbounded.FullHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.unbounded.ScriptHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.unbounded.ValueHistogramFacetCollector;
import org.elasticsearch.search.facet.histogram.unbounded.ValueScriptHistogramFacetCollector;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
@ -113,7 +117,7 @@ public class HistogramFacetProcessor extends AbstractComponent implements FacetP
}
if (sFrom != null && sTo != null && keyField != null) {
FieldMapper mapper = context.mapperService().smartNameFieldMapper(keyField);
FieldMapper mapper = context.smartNameFieldMapper(keyField);
if (mapper == null) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for key_field [" + keyField + "]");
}

View File

@ -53,13 +53,13 @@ public class BoundedCountHistogramFacetCollector extends AbstractFacetCollector
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -24,7 +24,6 @@ import org.elasticsearch.common.CacheRecycler;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
@ -62,25 +61,25 @@ public class BoundedValueHistogramFacetCollector extends AbstractFacetCollector
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + keyFieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
keyIndexFieldName = smartMappers.mapper().names().indexName();
keyFieldDataType = smartMappers.mapper().fieldDataType();
FieldMapper mapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (mapper == null) {
smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for value_field [" + valueFieldName + "]");
}
valueIndexFieldName = mapper.names().indexName();
valueFieldDataType = mapper.fieldDataType();
valueIndexFieldName = smartMappers.mapper().names().indexName();
valueFieldDataType = smartMappers.mapper().fieldDataType();
long normalizedFrom = (((long) ((double) from / interval)) * interval);
long normalizedTo = (((long) ((double) to / interval)) * interval);

View File

@ -61,13 +61,13 @@ public class BoundedValueScriptHistogramFacetCollector extends AbstractFacetColl
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -60,13 +60,13 @@ public class CountHistogramFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -60,13 +60,13 @@ public class FullHistogramFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -25,7 +25,6 @@ import org.elasticsearch.common.trove.ExtTLongObjectHashMap;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
@ -65,25 +64,25 @@ public class ValueHistogramFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + keyFieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
keyIndexFieldName = smartMappers.mapper().names().indexName();
keyFieldDataType = smartMappers.mapper().fieldDataType();
FieldMapper mapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (mapper == null) {
smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for value_field [" + valueFieldName + "]");
}
valueIndexFieldName = mapper.names().indexName();
valueFieldDataType = mapper.fieldDataType();
valueIndexFieldName = smartMappers.mapper().names().indexName();
valueFieldDataType = smartMappers.mapper().fieldDataType();
histoProc = new HistogramProc(interval);
}

View File

@ -65,13 +65,13 @@ public class ValueScriptHistogramFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -23,7 +23,6 @@ import org.apache.lucene.index.IndexReader;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
@ -57,25 +56,25 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector {
this.entries = entries;
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + keyFieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
keyIndexFieldName = smartMappers.mapper().names().indexName();
keyFieldDataType = smartMappers.mapper().fieldDataType();
FieldMapper mapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (mapper == null) {
smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for value_field [" + valueFieldName + "]");
}
valueIndexFieldName = mapper.names().indexName();
valueFieldDataType = mapper.fieldDataType();
valueIndexFieldName = smartMappers.mapper().names().indexName();
valueFieldDataType = smartMappers.mapper().fieldDataType();
this.rangeProc = new RangeProc(entries);
}

View File

@ -53,13 +53,13 @@ public class RangeFacetCollector extends AbstractFacetCollector {
this.fieldDataCache = context.fieldDataCache();
this.entries = entries;
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -118,7 +118,7 @@ public class RangeFacetProcessor extends AbstractComponent implements FacetProce
// fix the range entries if needed
if (keyField != null) {
FieldMapper mapper = context.mapperService().smartNameFieldMapper(keyField);
FieldMapper mapper = context.smartNameFieldMapper(keyField);
if (mapper == null) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for key_field [" + keyField + "]");
}

View File

@ -50,13 +50,13 @@ public class StatisticalFacetCollector extends AbstractFacetCollector {
super(facetName);
this.fieldDataCache = context.fieldDataCache();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldName + "]");
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}

View File

@ -56,7 +56,7 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector {
for (int i = 0; i < fieldsNames.length; i++) {
FieldMapper mapper = context.mapperService().smartNameFieldMapper(fieldsNames[i]);
FieldMapper mapper = context.smartNameFieldMapper(fieldsNames[i]);
if (mapper == null) {
throw new FacetPhaseExecutionException(facetName, "No mapping found for field [" + fieldsNames[i] + "]");
}

View File

@ -150,7 +150,7 @@ public class TermsFacetProcessor extends AbstractComponent implements FacetProce
return new ScriptTermsStringFieldFacetCollector(facetName, size, comparatorType, context, excluded, pattern, scriptLang, script, params);
}
FieldMapper fieldMapper = context.mapperService().smartNameFieldMapper(field);
FieldMapper fieldMapper = context.smartNameFieldMapper(field);
if (fieldMapper != null) {
if (fieldMapper instanceof IpFieldMapper) {
if (script != null || "map".equals(executionHint)) {

View File

@ -77,12 +77,13 @@ public class TermsByteFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms short facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -92,7 +93,6 @@ public class TermsByteFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,13 @@ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms byte facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +96,6 @@ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -77,12 +77,12 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms double facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -92,7 +92,6 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,12 @@ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms double facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +95,6 @@ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -77,12 +77,12 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms float facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -92,7 +92,6 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,12 @@ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms float facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +95,6 @@ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -77,12 +77,12 @@ public class TermsIntFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms int facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -92,7 +92,6 @@ public class TermsIntFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,12 @@ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms int facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +95,6 @@ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -74,12 +74,12 @@ public class TermsIpFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -89,7 +89,6 @@ public class TermsIpFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,12 @@ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +95,6 @@ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -87,12 +87,12 @@ public class TermsLongFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -102,7 +102,6 @@ public class TermsLongFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,12 @@ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +95,6 @@ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -77,12 +77,12 @@ public class TermsShortFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms short facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -92,7 +92,6 @@ public class TermsShortFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (script != null) {
this.script = context.scriptService().search(context.lookup(), scriptLang, script, params);

View File

@ -80,12 +80,12 @@ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms short facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -95,7 +95,6 @@ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -80,7 +80,7 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector {
indexFieldsNames = new String[fieldsNames.length];
for (int i = 0; i < fieldsNames.length; i++) {
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldsNames[i]);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldsNames[i]);
if (smartMappers == null || !smartMappers.hasMapper()) {
this.indexFieldsNames[i] = fieldsNames[i];
this.fieldsDataType[i] = FieldDataType.DefaultTypes.STRING;

View File

@ -86,7 +86,7 @@ public class TermsStringFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
this.indexFieldName = fieldName;
this.fieldDataType = FieldDataType.DefaultTypes.STRING;

View File

@ -83,12 +83,12 @@ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it");
} else {
}
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -98,7 +98,6 @@ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector {
this.indexFieldName = smartMappers.mapper().names().indexName();
this.fieldDataType = smartMappers.mapper().fieldDataType();
}
if (excluded == null || excluded.isEmpty()) {
this.excluded = null;

View File

@ -99,7 +99,7 @@ public class TermsStatsFacetProcessor extends AbstractComponent implements Facet
throw new FacetPhaseExecutionException(facetName, "either [value_field] or [script] are required to be set for terms stats facet");
}
FieldMapper keyFieldMapper = context.mapperService().smartNameFieldMapper(keyField);
FieldMapper keyFieldMapper = context.smartNameFieldMapper(keyField);
if (keyFieldMapper != null) {
if (keyFieldMapper.fieldDataType() == FieldDataType.DefaultTypes.LONG) {
return new TermsStatsLongFacetCollector(facetName, keyField, valueField, size, comparatorType, context, scriptLang, script, params);

View File

@ -29,7 +29,6 @@ import org.elasticsearch.common.trove.ExtTDoubleObjectHashMap;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.SearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
@ -75,13 +74,13 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
this.keyFieldName = keyFieldName;
this.keyFieldDataType = FieldDataType.DefaultTypes.STRING;
} else {
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -90,12 +89,12 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector {
}
if (script == null) {
FieldMapper fieldMapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (fieldMapper == null) {
smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("failed to find mappings for [" + valueFieldName + "]");
}
this.valueFieldName = fieldMapper.names().indexName();
this.valueFieldDataType = fieldMapper.fieldDataType();
this.valueFieldName = smartMappers.mapper().names().indexName();
this.valueFieldDataType = smartMappers.mapper().fieldDataType();
this.script = null;
this.aggregator = new Aggregator();
} else {

View File

@ -29,7 +29,6 @@ import org.elasticsearch.common.trove.ExtTLongObjectHashMap;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.SearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
@ -76,13 +75,13 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
this.keyFieldName = keyFieldName;
this.keyFieldDataType = FieldDataType.DefaultTypes.STRING;
} else {
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -91,12 +90,12 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector {
}
if (script == null) {
FieldMapper fieldMapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (fieldMapper == null) {
smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("failed to find mappings for [" + valueFieldName + "]");
}
this.valueFieldName = fieldMapper.names().indexName();
this.valueFieldDataType = fieldMapper.fieldDataType();
this.valueFieldName = smartMappers.mapper().names().indexName();
this.valueFieldDataType = smartMappers.mapper().fieldDataType();
this.script = null;
this.aggregator = new Aggregator();
} else {

View File

@ -30,7 +30,6 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldData;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.SearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
@ -76,13 +75,13 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector {
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(keyFieldName);
MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(keyFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
this.keyFieldName = keyFieldName;
this.keyFieldDataType = FieldDataType.DefaultTypes.STRING;
} else {
// add type filter if there is exact doc mapper associated with it
if (smartMappers.hasDocMapper()) {
if (smartMappers.hasDocMapper() && smartMappers.explicitTypeInName()) {
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
@ -91,12 +90,12 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector {
}
if (script == null) {
FieldMapper fieldMapper = context.mapperService().smartNameFieldMapper(valueFieldName);
if (fieldMapper == null) {
smartMappers = context.smartFieldMappers(valueFieldName);
if (smartMappers == null || !smartMappers.hasMapper()) {
throw new ElasticSearchIllegalArgumentException("failed to find mappings for [" + valueFieldName + "]");
}
this.valueFieldName = fieldMapper.names().indexName();
this.valueFieldDataType = fieldMapper.fieldDataType();
this.valueFieldName = smartMappers.mapper().names().indexName();
this.valueFieldDataType = smartMappers.mapper().fieldDataType();
this.script = null;
this.aggregator = new Aggregator();
} else {

View File

@ -98,7 +98,7 @@ public class FetchPhase implements SearchPhase {
} else {
FieldMappersFieldSelector fieldSelectorMapper = new FieldMappersFieldSelector();
for (String fieldName : context.fieldNames()) {
FieldMappers x = context.mapperService().smartNameFieldMappers(fieldName);
FieldMappers x = context.smartNameFieldMappers(fieldName);
if (x != null && x.mapper().stored()) {
fieldSelectorMapper.add(x);
} else {

View File

@ -34,6 +34,8 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.cache.filter.FilterCache;
import org.elasticsearch.index.cache.id.IdCache;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.FieldMappers;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.IndexQueryParserService;
import org.elasticsearch.index.query.ParsedQuery;
@ -532,4 +534,16 @@ public class SearchContext implements Releasable {
}
nestedQueries.put(scope, query);
}
public MapperService.SmartNameFieldMappers smartFieldMappers(String name) {
return mapperService().smartName(name, types);
}
public FieldMappers smartNameFieldMappers(String name) {
return mapperService().smartNameFieldMappers(name, types);
}
public FieldMapper smartNameFieldMapper(String name) {
return mapperService().smartNameFieldMapper(name, types);
}
}

View File

@ -138,7 +138,7 @@ public class SortParseElement implements SearchParseElement {
sortFields.add(SORT_DOC);
}
} else {
FieldMapper fieldMapper = context.mapperService().smartNameFieldMapper(fieldName);
FieldMapper fieldMapper = context.smartNameFieldMapper(fieldName);
if (fieldMapper == null) {
throw new SearchParseException(context, "No mapping found for [" + fieldName + "]");
}

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_bounding_box" : {
"person.location" : {
"location" : {
"top_left" : [-70, 40],
"bottom_right" : [-80, 30]
},

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_bounding_box" : {
"person.location" : {
"location" : {
"top_left" : [-70, 40],
"bottom_right" : [-80, 30]
}

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_bounding_box" : {
"person.location" : {
"location" : {
"top_left" : {
"lat" : 40,
"lon" : -70

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_bounding_box" : {
"person.location" : {
"location" : {
"top_left" : "40, -70",
"bottom_right" : "30, -80"
}

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_bounding_box" : {
"person.location" : {
"location" : {
"top_left" : "drn5x1g8cu2y",
"bottom_right" : "30, -80"
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "12mi",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
},

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "12mi",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -7,7 +7,7 @@
"geo_distance" : {
"distance" : 19.312128,
"unit": "km",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "19.312128km",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -7,7 +7,7 @@
"geo_distance" : {
"distance" : "12mi",
"unit": "km",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "12mi",
"person.location" : [-70, 40]
"location" : [-70, 40]
}
}
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "12mi",
"person.location" : "40, -70"
"location" : "40, -70"
}
}
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "12mi",
"person.location" : "drn5x1g8cu2y"
"location" : "drn5x1g8cu2y"
}
}
}

View File

@ -7,7 +7,7 @@
"geo_distance" : {
"distance" : 12,
"unit": "mi",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -7,7 +7,7 @@
"geo_distance" : {
"distance" : "12",
"unit": "mi",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : "19.312128",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -6,7 +6,7 @@
"filter" : {
"geo_distance" : {
"distance" : 19.312128,
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -7,7 +7,7 @@
"geo_distance" : {
"distance" : "19.312128",
"unit": "km",
"person.location" : {
"location" : {
"lat" : 40,
"lon" : -70
}

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_polygon" : {
"person.location" : {
"location" : {
"points" : [
[-70, 40],
[-80, 30],

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_polygon" : {
"person.location" : {
"location" : {
"points" : [
[-70, 40],
[-80, 30],

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_polygon" : {
"person.location" : {
"location" : {
"points" : [
{
"lat" : 40,

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_polygon" : {
"person.location" : {
"location" : {
"points" : [
"40, -70",
"30, -80",

View File

@ -5,7 +5,7 @@
},
"filter" : {
"geo_polygon" : {
"person.location" : {
"location" : {
"points" : [
"drn5x1g8cu2y",
"30, -80",