Skip to content

Commit af179ab

Browse files
authored
[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 9031d07 commit af179ab

File tree

59 files changed

+4659
-2126
lines changed

Some content is hidden

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

59 files changed

+4659
-2126
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
@@ -2895,8 +2895,17 @@ public void testFindFileStructure() throws IOException {
28952895
FindFileStructureRequest request = new FindFileStructureRequest();
28962896
request.setSample(sample.getBytes(StandardCharsets.UTF_8));
28972897

2898-
FindFileStructureResponse response =
2899-
execute(request, machineLearningClient::findFileStructure, machineLearningClient::findFileStructureAsync);
2898+
FindFileStructureResponse response = execute(
2899+
request,
2900+
machineLearningClient::findFileStructure,
2901+
machineLearningClient::findFileStructureAsync,
2902+
RequestOptions.DEFAULT
2903+
.toBuilder()
2904+
.setWarningsHandler(
2905+
warnings -> Collections.singletonList(
2906+
"[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead."
2907+
).equals(warnings) == false
2908+
).build());
29002909

29012910
FileStructure structure = response.getFileStructure();
29022911

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
@@ -90,7 +90,7 @@
9090
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
9191
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
9292
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
93-
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
93+
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
9494
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
9595
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
9696
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
@@ -316,7 +316,6 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
316316
GetCalendarEventsAction.INSTANCE,
317317
PostCalendarEventsAction.INSTANCE,
318318
PersistJobAction.INSTANCE,
319-
FindFileStructureAction.INSTANCE,
320319
SetUpgradeModeAction.INSTANCE,
321320
PutDataFrameAnalyticsAction.INSTANCE,
322321
GetDataFrameAnalyticsAction.INSTANCE,
@@ -408,7 +407,9 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
408407
// Async Search
409408
SubmitAsyncSearchAction.INSTANCE,
410409
GetAsyncSearchAction.INSTANCE,
411-
DeleteAsyncResultAction.INSTANCE
410+
DeleteAsyncResultAction.INSTANCE,
411+
// Text Structure
412+
FindFileStructureAction.INSTANCE
412413
));
413414

414415
// 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.action.ActionRequest;
99
import org.elasticsearch.action.ActionRequestValidationException;
@@ -18,7 +18,7 @@
1818
import org.elasticsearch.common.xcontent.StatusToXContentObject;
1919
import org.elasticsearch.common.xcontent.XContentBuilder;
2020
import org.elasticsearch.rest.RestStatus;
21-
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructure;
21+
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructure;
2222

2323
import java.io.IOException;
2424
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.common.ParseField;
99
import org.elasticsearch.common.Strings;
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;
@@ -25,7 +25,7 @@
2525
import java.util.TreeMap;
2626

2727
/**
28-
* Stores the file format determined by Machine Learning.
28+
* Stores the determined file format.
2929
*/
3030
public class FileStructure implements ToXContentObject, Writeable {
3131

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
@@ -73,7 +73,7 @@
7373
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
7474
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
7575
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
76-
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
76+
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
7777
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
7878
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
7979
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)