-
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
Deprecate types in get field mapping API #37667
Deprecate types in get field mapping API #37667
Conversation
Pinging @elastic/es-search |
- Add deprecation warning to RestGetFieldMappingAction - Add two new java HRLC classes GetFieldMappingsRequest and GetFieldMappingsResponse. These classes use new typeless forms of a request and response, and differ in that from the server versions. Relates to elastic#35190
05aee75
to
9e0801c
Compare
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 @mayya-sharipova, this is looking really nice to me! I'll add @hub-cap as a reviewer as he might want to follow along with the HLRC changes.
@@ -40,6 +40,24 @@ public void setUpAction() { | |||
new RestGetFieldMappingAction(Settings.EMPTY, controller()); | |||
} | |||
|
|||
public void testIncludeTypeName() { | |||
Map<String, String> params = new HashMap<>(); | |||
params.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); |
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 could randomly choose either "true"
or "false"
here, since both options should produce a deprecation message.
|
||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); | ||
|
||
public GetFieldMappingsRequest() {} |
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.
Small comment: do we need this constructor?
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.
is nothing actually required here in the request? If not then it makes sense to remove it
} | ||
|
||
|
||
/** returns the retrieved field mapping. The return map keys are index and field (as specified in the request). */ |
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.
Small comment, we could format this comment more as typical javadoc (capital letters, newline after opening /**
).
final String mapping = randomBoolean() ? "{\"type\":\"string\"}" : "{\"type\":\"keyword\"}"; | ||
FieldMappingMetaData metaData = | ||
new FieldMappingMetaData("my field", new BytesArray(mapping)); | ||
fieldMappings.put("field" + k, metaData); |
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.
Small comment: I think it's more common to use randomAlphaOfLength(...)
instead of hardcoding names like "index" + i"
and "my field"
. Also would it make sense to sometimes choose FieldMappingMetaData.NULL
as well?
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.
++ to this
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.
@jtibshirani Thanks for the comment. I have removed FieldMappingMetaData.NULL
in the client GetFieldMappingsResponse
as it is not necessary. An empty FieldMappingMetaData
will indicate that field(s) are not found.
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 is some hairy parsing logic from the old code :) You might add a note to the old ones that mentions the new client side ones and how changes to the old parsing logic shouldnt differ from the client side ones as well, just so people know if they change it they should also change these... OH I CANT WAIT TILL WE ARE GENERATING THESE :P
Im LGTM once @jtibshirani is LGTM w the PR.
|
||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); | ||
|
||
public GetFieldMappingsRequest() {} |
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.
is nothing actually required here in the request? If not then it makes sense to remove it
final String mapping = randomBoolean() ? "{\"type\":\"string\"}" : "{\"type\":\"keyword\"}"; | ||
FieldMappingMetaData metaData = | ||
new FieldMappingMetaData("my field", new BytesArray(mapping)); | ||
fieldMappings.put("field" + k, metaData); |
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.
++ to this
@jtibshirani and @hub-cap thanks for the review. I have addressed all your comments. @jtibshirani This is ready for another review, whenever you have time. |
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.
Looks good to me as well, just left a couple non-critical comments.
/** Request the mappings of specific fields */ | ||
public class GetFieldMappingsRequest implements Validatable { | ||
|
||
protected boolean local = false; |
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.
Small comment, can this be private
?
int fields = randomInt(10); | ||
for (int k = 0; k < fields; k++) { | ||
final String mapping = randomBoolean() ? "{\"type\":\"string\"}" : "{\"type\":\"keyword\"}"; | ||
FieldMappingMetaData metaData = new FieldMappingMetaData("my field", new BytesArray(mapping)); |
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.
Small comment, "my field"
-> randomAlphaOfLength(8)
.
…ndices_get_field_mapping
…ead-de-duplication * elastic/master: Use explicit version for build-tools in example plugin integ tests (elastic#37792) Change `rational` to `saturation` in script_score (elastic#37766) Deprecate types in get field mapping API (elastic#37667) Add ability to listen to group of affix settings (elastic#37679) Ensure changes requests return the latest mapping version (elastic#37633) Make Minio Setup more Reliable (elastic#37747)
* elastic/master: (85 commits) Use explicit version for build-tools in example plugin integ tests (elastic#37792) Change `rational` to `saturation` in script_score (elastic#37766) Deprecate types in get field mapping API (elastic#37667) Add ability to listen to group of affix settings (elastic#37679) Ensure changes requests return the latest mapping version (elastic#37633) Make Minio Setup more Reliable (elastic#37747) Liberalize StreamOutput#writeStringList (elastic#37768) Add PersistentTasksClusterService::unassignPersistentTask method (elastic#37576) Tests: disable testRandomGeoCollectionQuery on tiny polygons (elastic#37579) Use ILM for Watcher history deletion (elastic#37443) Make sure PutMappingRequest accepts content types other than JSON. (elastic#37720) Retry ILM steps that fail due to SnapshotInProgressException (elastic#37624) Use disassociate in preference to deassociate (elastic#37704) Delete Redundant RoutingServiceTests (elastic#37750) Always return metadata version if metadata is requested (elastic#37674) [TEST] Mute MlMappingsUpgradeIT testMappingsUpgrade Streamline skip_unavailable handling (elastic#37672) Only bootstrap and elect node in current voting configuration (elastic#37712) Ensure either success or failure path for SearchOperationListener is called (elastic#37467) Target only specific index in update settings test ...
- Add deprecation warning to RestGetFieldMappingAction - Add two new java HRLC classes GetFieldMappingsRequest and GetFieldMappingsResponse. These classes use new typeless forms of a request and response, and differ in that from the server versions. Backport for elastic#37667 Relates to elastic#35190
GetFieldMappingsResponse. These classes use new typeless forms
of a request and response, and differ in that from the server
versions.
Relates to #35190