-
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?
Changes from all commits
92b1fc7
41118d5
5e06346
a5b419b
a41a53f
e861068
3bd9e63
0fd11f2
0174e26
0fe4b4a
b2a8b64
3aa6811
e421a22
d613743
783fb75
56d6c82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,7 +209,8 @@ public static final class Builder extends FieldMapper.DimensionBuilder { | |
private final IndexAnalyzers indexAnalyzers; | ||
private final ScriptCompiler scriptCompiler; | ||
private final IndexVersion indexCreatedVersion; | ||
private final boolean useDocValuesSkipper; | ||
private final boolean enableDocValuesSkipper; | ||
private final boolean forceDocValuesSkipper; | ||
private final SourceKeepMode indexSourceKeepMode; | ||
|
||
public Builder(final String name, final MappingParserContext mappingParserContext) { | ||
|
@@ -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()), | ||
false, | ||
mappingParserContext.getIndexSettings().sourceKeepMode() | ||
); | ||
} | ||
|
@@ -243,6 +245,7 @@ public Builder(final String name, final MappingParserContext mappingParserContex | |
IndexMode.STANDARD, | ||
null, | ||
false, | ||
false, | ||
sourceKeepMode | ||
); | ||
} | ||
|
@@ -255,7 +258,8 @@ private Builder( | |
IndexVersion indexCreatedVersion, | ||
IndexMode indexMode, | ||
IndexSortConfig indexSortConfig, | ||
boolean useDocValuesSkipper, | ||
boolean enableDocValuesSkipper, | ||
boolean forceDocValuesSkipper, | ||
SourceKeepMode indexSourceKeepMode | ||
) { | ||
super(name); | ||
|
@@ -293,14 +297,36 @@ private Builder( | |
}); | ||
this.indexSortConfig = indexSortConfig; | ||
this.indexMode = indexMode; | ||
this.useDocValuesSkipper = useDocValuesSkipper; | ||
this.enableDocValuesSkipper = enableDocValuesSkipper; | ||
this.forceDocValuesSkipper = forceDocValuesSkipper; | ||
this.indexSourceKeepMode = indexSourceKeepMode; | ||
} | ||
|
||
public Builder(String name, IndexVersion indexCreatedVersion) { | ||
this(name, null, ScriptCompiler.NONE, Integer.MAX_VALUE, indexCreatedVersion, SourceKeepMode.NONE); | ||
} | ||
|
||
public static Builder buildWithDocValuesSkipper( | ||
String name, | ||
IndexMode indexMode, | ||
IndexVersion indexCreatedVersion, | ||
boolean enableDocValuesSkipper | ||
) { | ||
return new Builder( | ||
name, | ||
null, | ||
ScriptCompiler.NONE, | ||
Integer.MAX_VALUE, | ||
indexCreatedVersion, | ||
indexMode, | ||
// Sort config is used to decide if DocValueSkippers can be used. Since skippers are forced, a sort config is not needed. | ||
null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 |
||
enableDocValuesSkipper, | ||
true, | ||
SourceKeepMode.NONE | ||
); | ||
} | ||
|
||
public Builder ignoreAbove(int ignoreAbove) { | ||
this.ignoreAbove.setValue(ignoreAbove); | ||
return this; | ||
|
@@ -422,7 +448,9 @@ private KeywordFieldType buildFieldType(MapperBuilderContext context, FieldType | |
@Override | ||
public KeywordFieldMapper build(MapperBuilderContext context) { | ||
FieldType fieldtype = resolveFieldType( | ||
useDocValuesSkipper, | ||
enableDocValuesSkipper, | ||
forceDocValuesSkipper, | ||
hasDocValues, | ||
indexCreatedVersion, | ||
indexSortConfig, | ||
indexMode, | ||
|
@@ -460,24 +488,30 @@ public KeywordFieldMapper build(MapperBuilderContext context) { | |
buildFieldType(context, fieldtype), | ||
builderParams(this, context), | ||
context.isSourceSynthetic(), | ||
useDocValuesSkipper, | ||
this, | ||
offsetsFieldName, | ||
indexSourceKeepMode | ||
); | ||
} | ||
|
||
private FieldType resolveFieldType( | ||
final boolean useDocValuesSkipper, | ||
private static FieldType resolveFieldType( | ||
final boolean enableDocValuesSkipper, | ||
final boolean forceDocValuesSkipper, | ||
final Parameter<Boolean> hasDocValues, | ||
final IndexVersion indexCreatedVersion, | ||
final IndexSortConfig indexSortConfig, | ||
final IndexMode indexMode, | ||
final String fullFieldName | ||
) { | ||
if (useDocValuesSkipper | ||
&& indexCreatedVersion.onOrAfter(IndexVersions.HOSTNAME_DOC_VALUES_SPARSE_INDEX) | ||
&& shouldUseDocValuesSkipper(hasDocValues.getValue(), indexSortConfig, indexMode, fullFieldName)) { | ||
return new FieldType(Defaults.FIELD_TYPE_WITH_SKIP_DOC_VALUES); | ||
if (enableDocValuesSkipper) { | ||
if (forceDocValuesSkipper) { | ||
assert hasDocValues.getValue(); | ||
return new FieldType(Defaults.FIELD_TYPE_WITH_SKIP_DOC_VALUES); | ||
} | ||
if (indexCreatedVersion.onOrAfter(IndexVersions.HOSTNAME_DOC_VALUES_SPARSE_INDEX) | ||
&& shouldUseDocValuesSkipper(hasDocValues.getValue(), indexSortConfig, indexMode, fullFieldName)) { | ||
return new FieldType(Defaults.FIELD_TYPE_WITH_SKIP_DOC_VALUES); | ||
} | ||
} | ||
return new FieldType(Defaults.FIELD_TYPE); | ||
} | ||
|
@@ -1088,7 +1122,8 @@ public String originalName() { | |
private final int ignoreAboveDefault; | ||
private final IndexMode indexMode; | ||
private final IndexSortConfig indexSortConfig; | ||
private final boolean useDocValuesSkipper; | ||
private final boolean enableDocValuesSkipper; | ||
private final boolean forceDocValuesSkipper; | ||
private final String offsetsFieldName; | ||
private final SourceKeepMode indexSourceKeepMode; | ||
private final String originalName; | ||
|
@@ -1099,7 +1134,6 @@ private KeywordFieldMapper( | |
KeywordFieldType mappedFieldType, | ||
BuilderParams builderParams, | ||
boolean isSyntheticSource, | ||
boolean useDocValuesSkipper, | ||
Builder builder, | ||
String offsetsFieldName, | ||
SourceKeepMode indexSourceKeepMode | ||
|
@@ -1120,7 +1154,8 @@ private KeywordFieldMapper( | |
this.ignoreAboveDefault = builder.ignoreAboveDefault; | ||
this.indexMode = builder.indexMode; | ||
this.indexSortConfig = builder.indexSortConfig; | ||
this.useDocValuesSkipper = useDocValuesSkipper; | ||
this.enableDocValuesSkipper = builder.enableDocValuesSkipper; | ||
this.forceDocValuesSkipper = builder.forceDocValuesSkipper; | ||
this.offsetsFieldName = offsetsFieldName; | ||
this.indexSourceKeepMode = indexSourceKeepMode; | ||
this.originalName = mappedFieldType.originalName(); | ||
|
@@ -1219,7 +1254,7 @@ private boolean indexValue(DocumentParserContext context, XContentString value) | |
throw new IllegalArgumentException(msg); | ||
} | ||
|
||
Field field = new KeywordField(fieldType().name(), binaryValue, fieldType); | ||
Field field = buildKeywordField(binaryValue); | ||
context.doc().add(field); | ||
|
||
if (fieldType().hasDocValues() == false && fieldType.omitNorms()) { | ||
|
@@ -1276,11 +1311,16 @@ public FieldMapper.Builder getMergeBuilder() { | |
indexCreatedVersion, | ||
indexMode, | ||
indexSortConfig, | ||
useDocValuesSkipper, | ||
enableDocValuesSkipper, | ||
forceDocValuesSkipper, | ||
indexSourceKeepMode | ||
).dimension(fieldType().isDimension()).init(this); | ||
} | ||
|
||
public Field buildKeywordField(BytesRef binaryValue) { | ||
return new KeywordField(fieldType().name(), binaryValue, fieldType); | ||
} | ||
|
||
@Override | ||
public void doValidate(MappingLookup lookup) { | ||
if (fieldType().isDimension() && null != lookup.nestedLookup().getNestedParent(fullPath())) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.