Skip to content
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

Conversation

mayya-sharipova
Copy link
Contributor

  • 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 #35190

@mayya-sharipova mayya-sharipova added v7.0.0 v6.7.0 >deprecation :Search Foundations/Mapping Index mappings, including merging and defining field types labels Jan 21, 2019
@elasticmachine
Copy link
Collaborator

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
Copy link
Contributor

@jtibshirani jtibshirani left a 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");
Copy link
Contributor

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() {}
Copy link
Contributor

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?

Copy link
Contributor

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). */
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

++ to this

Copy link
Contributor Author

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.

Copy link
Contributor

@hub-cap hub-cap left a 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() {}
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

++ to this

@mayya-sharipova
Copy link
Contributor Author

@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.

Copy link
Contributor

@jtibshirani jtibshirani left a 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;
Copy link
Contributor

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));
Copy link
Contributor

@jtibshirani jtibshirani Jan 22, 2019

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).

@mayya-sharipova mayya-sharipova merged commit c8565fe into elastic:master Jan 23, 2019
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 24, 2019
…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)
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 24, 2019
* 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
  ...
mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this pull request Jan 24, 2019
- 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
mayya-sharipova added a commit that referenced this pull request Jan 25, 2019
- 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 #37667
Relates to #35190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Search Foundations/Mapping Index mappings, including merging and defining field types v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants