-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add template_id to patterned-text type #131401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add template_id to patterned-text type #131401
Conversation
@@ -474,6 +496,10 @@ private FieldType resolveFieldType( | |||
final IndexMode indexMode, | |||
final String fullFieldName | |||
) { | |||
if (requireDocValueSkippers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems weird to have both useDocValuesSkipper
and requireDocValuesSkipper
fields. But I don't think it's a good idea to use the name-based way to deciding whether or not to use docValueSkippers. It seems like we should just enforce that they are always used for KeywordFields that are created for the purpose of being a templateId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads more like enableDocValuesSkipper
and useDocValuesSkipper
. Can we clean up the logic to apply this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We talked offline about changing useDocValuesSkipper
to enableDocValuesSkipper
and requireDocValuesSkipper
to forceDocValuesSkipper
. It's still a bit weird to have two such parameters, but one is needed to generally enable the use of doc values skippers, and another it needed for types (such as templateId) which are certain they want to use skippers, and don't require and name-based logic to decide (like host.name). With future changes to skippers, we can probably clean this up some.
Integer.MAX_VALUE, | ||
indexCreatedVersion, | ||
IndexMode.LOGSDB, | ||
null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be wiring a IndexSortConfig through here? I'm still a bit confused about how we want to control sorting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No index sorting will be explicitly configured for now, see:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also find it weird that it's propagated through this class.. Looking at the uses, I see shouldUseDocValuesSkipper
that's just inappropriate - this logic belongs to the LogsdbIndexModeSettingsProvider
that can inject a setting to enable skiplists when appropriate.
server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java
Outdated
Show resolved
Hide resolved
@@ -222,6 +223,7 @@ public Builder(final String name, final MappingParserContext mappingParserContex | |||
mappingParserContext.getIndexSettings().getMode(), | |||
mappingParserContext.getIndexSettings().getIndexSortConfig(), | |||
USE_DOC_VALUES_SKIPPER.get(mappingParserContext.getSettings()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this, or use regular indexing when this is not set? Maybe something to discuss with @martijnvg when he's back.
.../src/main/java/org/elasticsearch/xpack/logsdb/patternedtext/PatternedTextValueProcessor.java
Outdated
Show resolved
Hide resolved
...test/java/org/elasticsearch/xpack/logsdb/patternedtext/PatternedTextValueProcessorTests.java
Outdated
Show resolved
Hide resolved
search: | ||
index: test | ||
body: | ||
docvalue_fields: [ "foo.template_id" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test that it can be used in index sort config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, some minor comments.
Fixes #128937 |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
For patterned-text mapper
foo
, add a sub-field calledfoo.template_id
. This is the an 8-byte hash of the template doc_value column. Unlike the template,template_id
is accessible and can be used for querying, aggregations, etc. Thetemplate_id
is stored as a KeywordField and can use any features of the KeyworkFieldType.template_id
has doc_values, and is not stored or indexed. It uses doc value skippers, which should be quite fast given that the index will be sorted on template.