Class GeoContextMapping
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMapping<GeoQueryContext>
org.elasticsearch.search.suggest.completion.context.GeoContextMapping
- All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment
A
ContextMapping that uses a geo location/area as a
criteria.
The suggestions can be boosted and/or filtered depending on
whether it falls within an area, represented by a query geo hash
with a specified precision
GeoQueryContext defines the options for constructing
a unit of query context for this context type-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
ContextMapping.InternalQueryContext, ContextMapping.TypeNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params -
Field Summary
FieldsFields inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
FIELD_NAME, FIELD_TYPE, name, typeFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected GeoQueryContextfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)Prototype for the query contextintinthashCode()protected static GeoContextMappingparseContext(LuceneDocument document)Retrieves a set of context from adocumentat index-time.parseContext(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser)Parse a set ofCharSequencecontexts at index-time.protected org.elasticsearch.common.xcontent.XContentBuildertoInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)Implementations should add specific configurations that need to be persistedtoInternalQueryContexts(List<GeoQueryContext> queryContexts)Parse a list ofGeoQueryContextusingparser.voidvalidateReferences(Version indexVersionCreated, Function<String,MappedFieldType> fieldResolver)Checks if the current context is consistent with the rest of the fields.Methods inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
name, parseQueryContext, toString, toXContent, typeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
FIELD_PRECISION
- See Also:
- Constant Field Values
-
FIELD_FIELDNAME
- See Also:
- Constant Field Values
-
DEFAULT_PRECISION
public static final int DEFAULT_PRECISION- See Also:
- Constant Field Values
-
-
Method Details
-
getFieldName
-
getPrecision
public int getPrecision() -
load
-
toInnerXContent
protected org.elasticsearch.common.xcontent.XContentBuilder toInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOExceptionDescription copied from class:ContextMappingImplementations should add specific configurations that need to be persisted- Specified by:
toInnerXContentin classContextMapping<GeoQueryContext>- Throws:
IOException
-
parseContext
public Set<String> parseContext(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser) throws IOException, ElasticsearchParseExceptionParse a set ofCharSequencecontexts at index-time. Acceptable formats:- Array:
[<GEO POINT>, ..]
- String/Object/Array:
"GEO POINT"
GeoPoint(String)for GEO POINT- Specified by:
parseContextin classContextMapping<GeoQueryContext>- Throws:
IOExceptionElasticsearchParseException
- Array:
-
parseContext
Description copied from class:ContextMappingRetrieves a set of context from adocumentat index-time.- Specified by:
parseContextin classContextMapping<GeoQueryContext>
-
fromXContent
protected GeoQueryContext fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOExceptionDescription copied from class:ContextMappingPrototype for the query context- Specified by:
fromXContentin classContextMapping<GeoQueryContext>- Throws:
IOException
-
toInternalQueryContexts
public List<ContextMapping.InternalQueryContext> toInternalQueryContexts(List<GeoQueryContext> queryContexts)Parse a list ofGeoQueryContextusingparser. A QueryContexts accepts one of the following forms:- Object: GeoQueryContext
- String: GeoQueryContext value with boost=1 precision=PRECISION neighbours=[PRECISION]
- Array:
[GeoQueryContext, ..]
- Object:
GEO POINT
{"lat": <double>, "lon": <double>, "precision": <int>, "neighbours": <[int, ..]>}{"context": <string>, "boost": <int>, "precision": <int>, "neighbours": <[int, ..]>}{"context": <GEO POINT>, "boost": <int>, "precision": <int>, "neighbours": <[int, ..]>}
- String:
GEO POINT
GeoPoint(String)for GEO POINT- Specified by:
toInternalQueryContextsin classContextMapping<GeoQueryContext>
-
validateReferences
public void validateReferences(Version indexVersionCreated, Function<String,MappedFieldType> fieldResolver)Description copied from class:ContextMappingChecks if the current context is consistent with the rest of the fields. For example, the GeoContext should check that the field that it points to has the correct type.- Overrides:
validateReferencesin classContextMapping<GeoQueryContext>
-
equals
- Overrides:
equalsin classContextMapping<GeoQueryContext>
-
hashCode
public int hashCode()- Overrides:
hashCodein classContextMapping<GeoQueryContext>
-