Skip to content

Conversation

@jtibshirani
Copy link
Contributor

@jtibshirani jtibshirani commented Jun 26, 2020

This PR adds a version of XContentMapValues.extractValue that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured null_value instead of
'null' when retrieving fields.

@jtibshirani jtibshirani added >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types labels Jun 26, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jun 26, 2020
@jtibshirani jtibshirani requested a review from nik9000 June 26, 2020 21:16
@jtibshirani
Copy link
Contributor Author

I wasn't happy with how much complexity this added. It seems too inconsistent not to respect null_value though.

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a small question but I'm happy either way.

return XContentMapValues.extractValue(pathElements, 0, map, null);
}

@SuppressWarnings({"unchecked"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

/**
* A value to use in place of a {@code null} value in the document source.
*/
protected Object nullValue() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How bad would it be to make this abstract so implemeneters need to think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, null_value isn't a cross-cutting feature: only 9 out of ~40 field mappers implement it. In many cases it doesn't make that much sense (or could be harmful?), like setting a null_value for a geopoint. So I'm inclined to avoid making it abstract and encouraging mappers to implement it.

@jtibshirani
Copy link
Contributor Author

Thanks @nik9000 for reviewing !

@jtibshirani jtibshirani merged this pull request into elastic:field-retrieval Jun 30, 2020
@jtibshirani jtibshirani deleted the null-value branch June 30, 2020 20:39
jtibshirani added a commit that referenced this pull request Jun 30, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit that referenced this pull request Jul 8, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit that referenced this pull request Jul 14, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit that referenced this pull request Jul 15, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit that referenced this pull request Jul 18, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit that referenced this pull request Jul 21, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit that referenced this pull request Jul 23, 2020
…58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
jtibshirani added a commit to jtibshirani/elasticsearch that referenced this pull request Jul 27, 2020
…lastic#58623)

This PR adds a version of `XContentMapValues.extractValue` that accepts a
default value to return in place of 'null'. It then uses this method when
looking up source values to return the configured `null_value` instead of
'null' when retrieving fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants