Skip to content

Commit 65690ee

Browse files
authored
[7.x] [ML] move find file structure to a new API endpoint (#67123) (#67251)
* [ML] move find file structure to a new API endpoint (#67123) This introduces a new `text-structure` plugin. This is the new home of the find file structure API. The old REST URL is still available but is deprecated. The new URL is: `_text_structure/find_structure`. All parameters and behavior are unchanged. Changes to the high-level REST client and docs will be in separate commit. related to: #67001
1 parent 59a3f2e commit 65690ee

File tree

60 files changed

+4934
-2190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4934
-2190
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,8 +2929,17 @@ public void testFindFileStructure() throws IOException {
29292929
FindFileStructureRequest request = new FindFileStructureRequest();
29302930
request.setSample(sample.getBytes(StandardCharsets.UTF_8));
29312931

2932-
FindFileStructureResponse response =
2933-
execute(request, machineLearningClient::findFileStructure, machineLearningClient::findFileStructureAsync);
2932+
FindFileStructureResponse response = execute(
2933+
request,
2934+
machineLearningClient::findFileStructure,
2935+
machineLearningClient::findFileStructureAsync,
2936+
RequestOptions.DEFAULT
2937+
.toBuilder()
2938+
.setWarningsHandler(
2939+
warnings -> Collections.singletonList(
2940+
"[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead."
2941+
).equals(warnings) == false
2942+
).build());
29342943

29352944
FileStructure structure = response.getFileStructure();
29362945

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,8 +1870,17 @@ public void testFindFileStructure() throws Exception {
18701870
// end::find-file-structure-request-options
18711871

18721872
// tag::find-file-structure-execute
1873-
FindFileStructureResponse findFileStructureResponse =
1874-
client.machineLearning().findFileStructure(findFileStructureRequest, RequestOptions.DEFAULT);
1873+
FindFileStructureResponse findFileStructureResponse = client
1874+
.machineLearning()
1875+
.findFileStructure(
1876+
findFileStructureRequest,
1877+
RequestOptions.DEFAULT
1878+
.toBuilder()
1879+
.setWarningsHandler(
1880+
warnings -> Collections.singletonList(
1881+
"[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead."
1882+
).equals(warnings) == false
1883+
).build());
18751884
// end::find-file-structure-execute
18761885

18771886
// tag::find-file-structure-response

docs/reference/ml/anomaly-detection/apis/find-file-structure.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ POST _ml/find_file_structure
278278
{"name": "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304}
279279
{"name": "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288}
280280
----
281+
// TEST[warning:[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead.]
281282

282283
If the request does not encounter errors, you receive the following result:
283284

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
107107
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
108108
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
109-
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
109+
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
110110
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
111111
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
112112
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
@@ -398,7 +398,6 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
398398
GetCalendarEventsAction.INSTANCE,
399399
PostCalendarEventsAction.INSTANCE,
400400
PersistJobAction.INSTANCE,
401-
FindFileStructureAction.INSTANCE,
402401
SetUpgradeModeAction.INSTANCE,
403402
PutDataFrameAnalyticsAction.INSTANCE,
404403
GetDataFrameAnalyticsAction.INSTANCE,
@@ -506,7 +505,9 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
506505
CreateDataStreamAction.INSTANCE,
507506
GetDataStreamAction.INSTANCE,
508507
DeleteDataStreamAction.INSTANCE,
509-
DataStreamsStatsAction.INSTANCE
508+
DataStreamsStatsAction.INSTANCE,
509+
// Text Structure
510+
FindFileStructureAction.INSTANCE
510511
));
511512

512513
// rollupV2
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.ml.action;
6+
package org.elasticsearch.xpack.core.textstructure.action;
77

88
import org.elasticsearch.Version;
99
import org.elasticsearch.action.ActionRequest;
@@ -21,7 +21,7 @@
2121
import org.elasticsearch.common.xcontent.StatusToXContentObject;
2222
import org.elasticsearch.common.xcontent.XContentBuilder;
2323
import org.elasticsearch.rest.RestStatus;
24-
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructure;
24+
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructure;
2525

2626
import java.io.IOException;
2727
import java.util.Arrays;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.ml.filestructurefinder;
6+
package org.elasticsearch.xpack.core.textstructure.structurefinder;
77

88
import org.elasticsearch.Version;
99
import org.elasticsearch.common.ParseField;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.ml.filestructurefinder;
6+
package org.elasticsearch.xpack.core.textstructure.structurefinder;
77

88
import org.elasticsearch.common.ParseField;
99
import org.elasticsearch.common.io.stream.StreamInput;
@@ -26,7 +26,7 @@
2626
import java.util.TreeMap;
2727

2828
/**
29-
* Stores the file format determined by Machine Learning.
29+
* Stores the determined file format.
3030
*/
3131
public class FileStructure implements ToXContentObject, Writeable {
3232

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
7575
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
7676
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
77-
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
77+
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
7878
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
7979
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
8080
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.ml.action;
6+
package org.elasticsearch.xpack.core.textstructure.action;
77

88
import org.elasticsearch.action.ActionRequestValidationException;
99
import org.elasticsearch.common.bytes.BytesArray;
1010
import org.elasticsearch.common.io.stream.Writeable;
1111
import org.elasticsearch.test.AbstractWireSerializingTestCase;
12-
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructure;
12+
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructure;
1313

1414
import java.util.Arrays;
1515

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.core.ml.action;
6+
package org.elasticsearch.xpack.core.textstructure.action;
77

88
import org.elasticsearch.common.io.stream.Writeable;
99
import org.elasticsearch.test.AbstractWireSerializingTestCase;
10-
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructureTests;
10+
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
11+
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructureTests;
1112

1213
public class FindFileStructureActionResponseTests extends AbstractWireSerializingTestCase<FindFileStructureAction.Response> {
1314

0 commit comments

Comments
 (0)