-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add serialization test for FieldMappers when include_defaults=true #58235
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
Conversation
Pinging @elastic/es-search (:Search/Mapping) |
Marked as |
@elasticmachine update branch |
@elasticmachine update branch |
@@ -917,7 +917,8 @@ protected boolean docValuesByDefault() { | |||
@Override | |||
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { | |||
super.doXContentBody(builder, includeDefaults, params); | |||
if (includeDefaults || (mappedFieldType.isSearchable() && fieldType.indexOptions() != Defaults.FIELD_TYPE.indexOptions())) { | |||
if ((includeDefaults && fieldType.indexOptions() != IndexOptions.NONE) | |||
|| (mappedFieldType.isSearchable() && fieldType.indexOptions() != Defaults.FIELD_TYPE.indexOptions())) { |
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 struggle to parse this. why do we need to look at both indexOptions and isSearchable? When iis the second condition true in reality?
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.
Hm, you're right, we don't need the isSearchable
bit there - will update, thanks!
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.
Have pushed a change which simplifies this
@elasticmachine run elasticsearch-ci/packaging-sample-unix-packages |
This has resolved the initial issue with non-indexed
Here is a full example for what Kibana is using. The default distribution is required since it includes flattened types:
mapping.txt
|
@@ -917,7 +917,8 @@ protected boolean docValuesByDefault() { | |||
@Override | |||
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { | |||
super.doXContentBody(builder, includeDefaults, params); | |||
if (includeDefaults || (mappedFieldType.isSearchable() && fieldType.indexOptions() != Defaults.FIELD_TYPE.indexOptions())) { | |||
if (fieldType.indexOptions() != IndexOptions.NONE |
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.
so we don't want to print out index_options: none ? sorry I don't recall what we were doing before the refactoring.
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, if index
is set to false
then we don't emit the index_options
. The pre-existing method that converts the lucene IndexOptions
enum to a string doesn' accept IndexOptions.NONE
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.
thanks for explaining, makes sense
I had omitted to explicitly test the |
@elasticmachine update branch |
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
@@ -635,7 +635,8 @@ protected void parseCreateField(ParseContext context) throws IOException { | |||
@Override | |||
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { | |||
super.doXContentBody(builder, includeDefaults, params); | |||
if (includeDefaults || mappedFieldType.isSearchable() && fieldType.indexOptions() != Defaults.FIELD_TYPE.indexOptions()) { | |||
if (fieldType.indexOptions() != IndexOptions.NONE | |||
&& (includeDefaults || fieldType.indexOptions() != Defaults.FIELD_TYPE.indexOptions())) { |
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 logic is now duplicated in multiple places, I am tempted to ask if we can share it, on the other hand I am afraid it may complicate things and removing this duplication is not a priority at the moment.
…lastic#58235) Fixes a bug in TextFieldMapper serialization when index is false, and adds a base-class test to ensure that all field mappers are tested against all variations with defaults both included and excluded. Fixes elastic#58188
Fixes a bug in TextFieldMapper serialization when
index
isfalse
, and adds abase-class test to ensure that all field mappers are tested against all variations
with defaults both included and excluded.
Fixes #58188