Class GeoContextMapping
- java.lang.Object
-
- org.elasticsearch.search.suggest.completion.context.ContextMapping<GeoQueryContext>
-
- org.elasticsearch.search.suggest.completion.context.GeoContextMapping
-
- All Implemented Interfaces:
ToXContent,ToXContentFragment
public class GeoContextMapping extends ContextMapping<GeoQueryContext>
AContextMappingthat 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 precisionGeoQueryContextdefines the options for constructing a unit of query context for this context type
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGeoContextMapping.Builder-
Nested classes/interfaces inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
ContextMapping.InternalQueryContext, ContextMapping.Type
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PRECISIONstatic java.lang.StringFIELD_FIELDNAMEstatic java.lang.StringFIELD_PRECISION-
Fields inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
FIELD_NAME, FIELD_TYPE, name, type
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)protected GeoQueryContextfromXContent(XContentParser parser)Prototype for the query contextjava.lang.StringgetFieldName()intgetPrecision()inthashCode()protected static GeoContextMappingload(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> config)java.util.Set<java.lang.String>parseContext(ParseContext.Document document)Retrieves a set of context from adocumentat index-time.java.util.Set<java.lang.String>parseContext(ParseContext parseContext, XContentParser parser)Parse a set ofCharSequencecontexts at index-time.protected XContentBuildertoInnerXContent(XContentBuilder builder, ToXContent.Params params)Implementations should add specific configurations that need to be persistedjava.util.List<ContextMapping.InternalQueryContext>toInternalQueryContexts(java.util.List<GeoQueryContext> queryContexts)Parse a list ofGeoQueryContextusingparser.protected voidvalidateReferences(Version indexVersionCreated, java.util.function.Function<java.lang.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, type, validateContextPaths
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
FIELD_PRECISION
public static final java.lang.String FIELD_PRECISION
- See Also:
- Constant Field Values
-
FIELD_FIELDNAME
public static final java.lang.String FIELD_FIELDNAME
- See Also:
- Constant Field Values
-
DEFAULT_PRECISION
public static final int DEFAULT_PRECISION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFieldName
public java.lang.String getFieldName()
-
getPrecision
public int getPrecision()
-
load
protected static GeoContextMapping load(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> config)
-
toInnerXContent
protected XContentBuilder toInnerXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
Description copied from class:ContextMappingImplementations should add specific configurations that need to be persisted- Specified by:
toInnerXContentin classContextMapping<GeoQueryContext>- Throws:
java.io.IOException
-
parseContext
public java.util.Set<java.lang.String> parseContext(ParseContext parseContext, XContentParser parser) throws java.io.IOException, ElasticsearchParseException
Parse 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:
java.io.IOExceptionElasticsearchParseException
- Array:
-
parseContext
public java.util.Set<java.lang.String> parseContext(ParseContext.Document document)
Description copied from class:ContextMappingRetrieves a set of context from adocumentat index-time.- Specified by:
parseContextin classContextMapping<GeoQueryContext>
-
fromXContent
protected GeoQueryContext fromXContent(XContentParser parser) throws java.io.IOException
Description copied from class:ContextMappingPrototype for the query context- Specified by:
fromXContentin classContextMapping<GeoQueryContext>- Throws:
java.io.IOException
-
toInternalQueryContexts
public java.util.List<ContextMapping.InternalQueryContext> toInternalQueryContexts(java.util.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
protected void validateReferences(Version indexVersionCreated, java.util.function.Function<java.lang.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
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classContextMapping<GeoQueryContext>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classContextMapping<GeoQueryContext>
-
-