-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Use fallback synthetic source for copy_to and doc_values: false cases #112294
Conversation
97a1ea5
to
bda4de6
Compare
Hi @lkts, I've created a changelog YAML for you. |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
...apper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java
Show resolved
Hide resolved
} | ||
) | ||
); | ||
} |
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.
Shall we add a catch-all test to exercise copy_to
in all subclasses?
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 is tricky because copy_to only works with text-like data. F.e. for histogram
it does not work even though technically it is supported.
...rk/src/main/java/org/elasticsearch/index/mapper/TextFieldFamilySyntheticSourceTestSetup.java
Show resolved
Hide resolved
Oops, sorry for the merge conflicts.. I think if you just keep your version it should be good.. |
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.
LGTM
mode: synthetic | ||
properties: | ||
foo: | ||
type: match_only_text |
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.
if here we add store: true
...are we going to store the value twice?
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.
Yes but it is not necessarily the same value (e.g. normalizers).
id: "1" | ||
refresh: true | ||
body: | ||
foo: "Apache Lucene powers Elasticsearch" |
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 also test with an array of values?
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'll add them in a follow-up.
} | ||
|
||
var kwd = TextFieldMapper.SyntheticSourceHelper.getKeywordFieldMapperForSyntheticSource(this); | ||
if (kwd != null) { | ||
return kwd.syntheticFieldLoader(leafName()); | ||
return new SyntheticSourceSupport.Native(kwd.syntheticFieldLoader(leafName())); |
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.
Maybe we can consider naming the two synthetic source modes WithDocValues
and WithStoredFields
instead of Native
and Fallback
? Like:
SyntheticSourceSupport.WithDocValues
SyntheticSourceSupport.WithStoredFields
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.
That's not really the distinction i am trying to make. Yes, _ignored_source
is a stored field that holds the value used for synthetic source but it is also possible that the field itself uses a different stored field for synthetic source. That becomes pretty blurry.
The difference between Native
and Fallback
is who controls synthetic source logic. In Native
it's the mapper, in Fallback
it's on a layer above and the mapper does not control what happens.
mode: synthetic | ||
properties: | ||
annotated_text: | ||
type: annotated_text |
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.
Same as before...if we add store: true
do we store twice?
_source: | ||
mode: synthetic | ||
properties: | ||
number: |
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 test copy_to
in combination with ignore_above
and ignore_malformed
?
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 test it with ignore_malformed
for unsigned_long
f.e.
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.
ignore_above
is a good point, i'll follow up.
*/ | ||
protected enum SyntheticSourceMode { | ||
NATIVE, | ||
FALLBACK |
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.
Asked this above already: should we name these something like WITH_DOC_VALUES
and WITH_STORED_FIELDS
?
@@ -35,7 +35,8 @@ public Set<NodeFeature> getFeatures() { | |||
ObjectMapper.SUBOBJECTS_AUTO, | |||
KeywordFieldMapper.KEYWORD_NORMALIZER_SYNTHETIC_SOURCE, | |||
SourceFieldMapper.SYNTHETIC_SOURCE_STORED_FIELDS_ADVANCE_FIX, | |||
Mapper.SYNTHETIC_SOURCE_KEEP_FEATURE | |||
Mapper.SYNTHETIC_SOURCE_KEEP_FEATURE, | |||
SourceFieldMapper.SYNTHETIC_SOURCE_RESTRICTIONS_REMOVED |
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.
SYNTHETIC_SOURCE_WITH_COPY_TO_AND_DOC_VALUES_FALSE_SUPPORT
? I Know it is longer but much more descriptive.
} | ||
|
||
private Supplier<Map<String, Object>> scaledFloatMapping() { | ||
return () -> { | ||
var scalingFactor = ESTestCase.randomFrom(10, 1000, 100000, 100.5); | ||
return Map.of("scaling_factor", scalingFactor, "store", ESTestCase.randomBoolean(), "index", ESTestCase.randomBoolean()); | ||
return Map.of( | ||
"scaling_factor", |
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.
nit: indentation
73 files is quite a lot anyway |
Don't forget the PR description |
Hi @lkts, I've updated the changelog YAML for you. |
@elasticmachine update branch |
Closes #109546.
Closes #110038.
Closes #110753.