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 java.lang.String |
FIELD_FIELDNAME |
static java.lang.String |
FIELD_NEIGHBORS |
static java.lang.String |
FIELD_PRECISION |
static java.lang.String |
TYPE |
EMPTY_CONFIG, EMPTY_CONTEXT, EMPTY_MAPPING, FIELD_MISSING, FIELD_TYPE, FIELD_VALUE, name, SEPARATOR, typeEMPTY_PARAMS| Modifier | Constructor and Description |
|---|---|
protected |
GeolocationContextMapping(java.lang.String name,
int[] precision,
boolean neighbors,
java.util.Collection<java.lang.String> defaultLocations,
java.lang.String fieldName)
Create a new
GeolocationContextMapping with a given precision |
| Modifier and Type | Method and Description |
|---|---|
ContextMapping.ContextConfig |
defaultConfig() |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
protected static GeolocationContextMapping |
load(java.lang.String name,
java.util.Map<java.lang.String,java.lang.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.completion2x.context.GeolocationContextMapping.GeoQuery |
parseQuery(java.lang.String name,
XContentParser parser)
Parse a query according to the context.
|
protected static java.util.Collection<java.lang.String> |
parseSinglePointOrList(XContentParser parser) |
static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery |
query(java.lang.String name,
double lat,
double lon,
int... precisions)
Create a new geolocation query from a given geocoordinate
|
static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery |
query(java.lang.String name,
double lat,
double lon,
java.lang.String... precisions) |
static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery |
query(java.lang.String name,
GeoPoint point)
Create a new geolocation query from a given GeoPoint
|
static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery |
query(java.lang.String name,
java.lang.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, typeclone, finalize, getClass, notify, notifyAll, wait, wait, waitisFragmentpublic static final java.lang.String TYPE
public static final java.lang.String FIELD_PRECISION
public static final java.lang.String FIELD_NEIGHBORS
public static final java.lang.String FIELD_FIELDNAME
protected GeolocationContextMapping(java.lang.String name,
int[] precision,
boolean neighbors,
java.util.Collection<java.lang.String> defaultLocations,
java.lang.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(java.lang.String name, java.util.Map<java.lang.String,java.lang.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 java.io.IOException
ContextMappingtoInnerXContent in class ContextMappingbuilder - builder to append the mapping toparams - parameters passed to the builderjava.io.IOExceptionprotected static java.util.Collection<java.lang.String> parseSinglePointOrList(XContentParser parser) throws java.io.IOException
java.io.IOExceptionpublic ContextMapping.ContextConfig defaultConfig()
defaultConfig in class ContextMappingpublic ContextMapping.ContextConfig parseContext(ParseContext parseContext, XContentParser parser) throws java.io.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 mappingjava.io.IOExceptionElasticsearchParseExceptionpublic static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery query(java.lang.String name,
GeoPoint point)
point - query locationpublic static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery query(java.lang.String name,
double lat,
double lon,
int... precisions)
lat - latitude of the locationlon - longitude of the locationpublic static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery query(java.lang.String name,
double lat,
double lon,
java.lang.String... precisions)
public static org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery query(java.lang.String name,
java.lang.String geohash,
int... precisions)
geohash - geohash of the locationpublic org.elasticsearch.search.suggest.completion2x.context.GeolocationContextMapping.GeoQuery parseQuery(java.lang.String name,
XContentParser parser)
throws java.io.IOException,
ElasticsearchParseException
ContextMappingparseQuery in class ContextMappingname - name of the contextparser - XContentParser providing the data of the queryContextMapping.ContextQuery according to this mappingjava.io.IOExceptionElasticsearchParseExceptionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object