Module org.elasticsearch.server
Package org.elasticsearch.index.query
Class CoordinatorRewriteContext
java.lang.Object
org.elasticsearch.index.query.QueryRewriteContext
org.elasticsearch.index.query.CoordinatorRewriteContext
Context object used to rewrite
QueryBuilder instances into simplified version in the coordinator.
Instances of this object rely on information stored in the IndexMetadata for certain indices.
Right now this context object is able to rewrite range queries that include a known timestamp field
(i.e. the timestamp field for DataStreams or the 'event.ingested' field in ECS) into a MatchNoneQueryBuilder
and skip the shards that don't hold queried data. See IndexMetadata for more details.-
Field Summary
FieldsFields inherited from class org.elasticsearch.index.query.QueryRewriteContext
allowedFields, allowExpensiveQueries, allowUnmappedFields, client, fullyQualifiedIndex, indexNameMatcher, indexSettings, mapperService, mappingLookup, mapUnmappedFieldAsString, nowInMillis, runtimeMappings, scriptService, valuesSourceRegistry, writeableRegistry -
Constructor Summary
ConstructorsConstructorDescriptionCoordinatorRewriteContext(XContentParserConfiguration parserConfig, Client client, LongSupplier nowInMillis, DateFieldRangeInfo dateFieldRangeInfo, String tier) Context for coordinator search rewrites based on time ranges for the @timestamp field and/or 'event.ingested' field -
Method Summary
Modifier and TypeMethodDescriptionReturns an instance ofCoordinatorRewriteContextif available or null otherwisegetFieldRange(String fieldName) getFieldType(String fieldName) Returns theMappedFieldTypefor the provided field name.Retrieve the first tier preference from the index setting.Methods inherited from class org.elasticsearch.index.query.QueryRewriteContext
allowExpensiveQueries, convertToDataRewriteContext, convertToIndexMetadataContext, convertToInnerHitsRewriteContext, convertToSearchExecutionContext, executeAsyncActions, fieldType, getAllFields, getFullyQualifiedIndex, getIndexAnalyzers, getIndexSettings, getMappingLookup, getMatchingFieldNames, getParserConfig, getPointInTimeBuilder, getQueryRewriteInterceptor, getResolvedIndices, getValuesSourceRegistry, getWriteableRegistry, hasAsyncActions, indexMatches, isExplain, nowInMillis, registerAsyncAction, setAllowUnmappedFields, setMapUnmappedFieldAsString, setQueryRewriteInterceptor
-
Field Details
-
TIER_FIELD_NAME
- See Also:
-
SUPPORTED_FIELDS
-
-
Constructor Details
-
CoordinatorRewriteContext
public CoordinatorRewriteContext(XContentParserConfiguration parserConfig, Client client, LongSupplier nowInMillis, @Nullable DateFieldRangeInfo dateFieldRangeInfo, String tier) Context for coordinator search rewrites based on time ranges for the @timestamp field and/or 'event.ingested' field- Parameters:
parserConfig-client-nowInMillis-dateFieldRangeInfo- range and field type info for @timestamp and 'event.ingested'tier- the configured data tier (via the _tier_preference setting) for the index
-
-
Method Details
-
getFieldType
Description copied from class:QueryRewriteContextReturns theMappedFieldTypefor the provided field name. If the field is not mapped, the behaviour depends on the index.query.parse.allow_unmapped_fields setting, which defaults to true. In case unmapped fields are allowed, null is returned when the field is not mapped. In case unmapped fields are not allowed, either an exception is thrown or the field is automatically mapped as a text field.- Overrides:
getFieldTypein classQueryRewriteContext- Parameters:
fieldName- Must be one of DataStream.TIMESTAMP_FIELD_FIELD, IndexMetadata.EVENT_INGESTED_FIELD_NAME, or DataTierFiledMapper.NAME- Returns:
- MappedField with type for the field. Returns null if fieldName is not one of the allowed field names.
- See Also:
-
getFieldRange
- Parameters:
fieldName- Must be one of DataStream.TIMESTAMP_FIELD_FIELD or IndexMetadata.EVENT_INGESTED_FIELD_NAME- Returns:
- IndexLongFieldRange with min/max ranges for the field. Returns null if fieldName is not one of the allowed field names.
-
convertToCoordinatorRewriteContext
Description copied from class:QueryRewriteContextReturns an instance ofCoordinatorRewriteContextif available or null otherwise- Overrides:
convertToCoordinatorRewriteContextin classQueryRewriteContext
-
getTierPreference
Description copied from class:QueryRewriteContextRetrieve the first tier preference from the index setting. If the setting is not present, then return null.- Overrides:
getTierPreferencein classQueryRewriteContext
-