-
Notifications
You must be signed in to change notification settings - Fork 24.2k
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
Add a GetFieldMapping API #3942
Conversation
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field("fullName", fullName); | ||
builder.field("mapping"); | ||
builder.map(sourceAsMap()); |
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 write this field as "raw", see XContentHelper#rawField, so no need to convert it to a map?
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.
Done. Required moving the source to a ByteReference which is ok imo.
I am in the same boat as luca with putting Apart from that: from functionality point of view this is a huge +1 |
@javanna @spinscale thx for the review. Going back to the point you made about potentially having a |
on the fence on this as well, leaning towards the current solution, where the serialization of a single mapping attribute is done in a single place (compared to over several places). |
I was more leaning towards a common method that does the |
|
||
private static final ToXContent.Params includeDefaultsParams = new ToXContent.Params() { | ||
|
||
final String INCLUDE_DEFAULTS = "include_defaults"; |
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.
private static too?
This new API allows to get the mapping for a specific set of fields rather than get the whole index mapping and traverse it. The fields to be retrieved can be specified by their full path, index name and field name and will be resolved in this order. In case multiple field match, the first one will be returned. Since we are now generating the output (rather then fall back to the stored mapping), you can specify `include_defaults`=true on the request to have default values returned. Closes elastic#3941
This new API allows to get the mapping for a specific set of fields rather than get the whole index mapping and traverse it.
The fields to be retrieved can be specified by their full path, index name and field name and will be resolved in this order.
In case multiple field match, the first one will be returned.
Since we are now generating the output (rather then fall back to the stored mapping), you can specify
include_defaults
=true on the request to have default values returned.Closes #3941