public class GeolocationContextMapping extends ContextMapping
GeolocationContextMapping allows to take GeoInfomation into account
during building suggestions. The mapping itself works with geohashes
explicitly and is configured by three parameters:
precision: length of the geohash indexed as prefix of the
completion fieldneighbors: Should the neighbor cells of the deepest geohash
level also be indexed as alternatives to the actual geohashlocation: (optional) location assumed if it is not provided[geohash][suggestion]. If the neighbor option is set the cells
next to the cell on the deepest geohash level ( precision) will
be indexed as well. The TokenStream used to build the FST for
suggestion will be wrapped into a PrefixAnalyzer.PrefixTokenFilter managing these
geohases as prefixes.| Modifier and Type | Class and Description |
|---|---|
static class |
GeolocationContextMapping.Builder |
ContextMapping.Context, ContextMapping.ContextConfig, ContextMapping.ContextQueryToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params| Modifier and Type | Field and Description |
|---|---|
static String |
FIELD_FIELDNAME |
static String |
FIELD_NEIGHBORS |
static String |
FIELD_PRECISION |
static String |
TYPE |
EMPTY_CONFIG, EMPTY_CONTEXT, EMPTY_MAPPING, FIELD_MISSING, FIELD_TYPE, FIELD_VALUE, name, SEPARATOR, typeEMPTY_PARAMS| Modifier | Constructor and Description |
|---|---|
protected |
GeolocationContextMapping(String name,
int[] precision,
boolean neighbors,
Collection<String> defaultLocations,
String fieldName)
Create a new
GeolocationContextMapping with a given precision |
| Modifier and Type | Method and Description |
|---|---|
ContextMapping.ContextConfig |
defaultConfig() |
boolean |
equals(Object obj) |
int |
hashCode() |
protected static GeolocationContextMapping |
load(String name,
Map<String,Object> config)
load a
GeolocationContextMapping by configuration. |
ContextMapping.ContextConfig |
parseContext(ParseContext parseContext,
XContentParser parser)
A
ContextMapping combined with the information provided by a document
form a ContextMapping.ContextConfig which is used to build the underlying FST. |
org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery |
parseQuery(String name,
XContentParser parser)
Parse a query according to the context.
|
protected static Collection<String> |
parseSinglePointOrList(XContentParser parser) |
static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery |
query(String name,
double lat,
double lon,
int... precisions)
Create a new geolocation query from a given geocoordinate
|
static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery |
query(String name,
double lat,
double lon,
String... precisions) |
static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery |
query(String name,
GeoPoint point)
Create a new geolocation query from a given GeoPoint
|
static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery |
query(String name,
String geohash,
int... precisions)
Create a new geolocation query from a given geohash
|
protected XContentBuilder |
toInnerXContent(XContentBuilder builder,
ToXContent.Params params)
Since every context mapping is assumed to have a name given by the field name of an context object, this
method is used to build the value used to serialize the mapping
|
mappingsAreEqual, name, toString, toXContent, typepublic static final String TYPE
public static final String FIELD_PRECISION
public static final String FIELD_NEIGHBORS
public static final String FIELD_FIELDNAME
protected GeolocationContextMapping(String name, int[] precision, boolean neighbors, Collection<String> defaultLocations, String fieldName)
GeolocationContextMapping with a given precisionprecision - length of the geohashesneighbors - should neighbors be indexeddefaultLocations - location to use, if it is not provided by the documentprotected static GeolocationContextMapping load(String name, Map<String,Object> config)
GeolocationContextMapping by configuration. Such a configuration
can set the parameters
String, Double,
Float or Integer] defines the length of the
underlying geohashString] defines the location to use if
it is not provided by the documentBoolean] defines if the last level of the
geohash should be extended by neighbor cellsconfig - Configuration for GeolocationContextMappingGeolocationContextMapping configured by the parameters of
configprotected XContentBuilder toInnerXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
ContextMappingtoInnerXContent in class ContextMappingbuilder - builder to append the mapping toparams - parameters passed to the builderIOExceptionprotected static Collection<String> parseSinglePointOrList(XContentParser parser) throws IOException
IOExceptionpublic ContextMapping.ContextConfig defaultConfig()
defaultConfig in class ContextMappingpublic ContextMapping.ContextConfig parseContext(ParseContext parseContext, XContentParser parser) throws IOException, ElasticsearchParseException
ContextMappingContextMapping combined with the information provided by a document
form a ContextMapping.ContextConfig which is used to build the underlying FST.parseContext in class ContextMappingparseContext - context of parsing phaseparser - XContentParser used to read and setup the configurationContextMapping.ContextConfig related to this mappingIOExceptionElasticsearchParseExceptionpublic static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery query(String name, GeoPoint point)
point - query locationpublic static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery query(String name, double lat, double lon, int... precisions)
lat - latitude of the locationlon - longitude of the locationpublic static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery query(String name, double lat, double lon, String... precisions)
public static org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery query(String name, String geohash, int... precisions)
geohash - geohash of the locationpublic org.elasticsearch.search.suggest.context.GeolocationContextMapping.GeoQuery parseQuery(String name, XContentParser parser) throws IOException, ElasticsearchParseException
ContextMappingparseQuery in class ContextMappingname - name of the contextparser - XContentParser providing the data of the queryContextMapping.ContextQuery according to this mappingIOExceptionElasticsearchParseExceptionCopyright © 2009–2017. All rights reserved.