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

[ML] move find file structure to a new API endpoint #67123

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2895,8 +2895,17 @@ public void testFindFileStructure() throws IOException {
FindFileStructureRequest request = new FindFileStructureRequest();
request.setSample(sample.getBytes(StandardCharsets.UTF_8));

FindFileStructureResponse response =
execute(request, machineLearningClient::findFileStructure, machineLearningClient::findFileStructureAsync);
FindFileStructureResponse response = execute(
Copy link
Member Author

Choose a reason for hiding this comment

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

This will probably be removed once the high level client is updated

request,
machineLearningClient::findFileStructure,
machineLearningClient::findFileStructureAsync,
RequestOptions.DEFAULT
.toBuilder()
.setWarningsHandler(
warnings -> Collections.singletonList(
"[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead."
).equals(warnings) == false
).build());

FileStructure structure = response.getFileStructure();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1870,8 +1870,17 @@ public void testFindFileStructure() throws Exception {
// end::find-file-structure-request-options

// tag::find-file-structure-execute
FindFileStructureResponse findFileStructureResponse =
client.machineLearning().findFileStructure(findFileStructureRequest, RequestOptions.DEFAULT);
FindFileStructureResponse findFileStructureResponse = client
Copy link
Member Author

Choose a reason for hiding this comment

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

This will probably be removed once the high level client is updated

.machineLearning()
.findFileStructure(
findFileStructureRequest,
RequestOptions.DEFAULT
.toBuilder()
.setWarningsHandler(
warnings -> Collections.singletonList(
"[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead."
).equals(warnings) == false
).build());
// end::find-file-structure-execute

// tag::find-file-structure-response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ POST _ml/find_file_structure
{"name": "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304}
{"name": "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288}
----
// TEST[warning:[POST /_ml/find_file_structure] is deprecated! Use [POST /_text_structure/find_structure] instead.]

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
Expand Down Expand Up @@ -316,7 +316,6 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
GetCalendarEventsAction.INSTANCE,
PostCalendarEventsAction.INSTANCE,
PersistJobAction.INSTANCE,
FindFileStructureAction.INSTANCE,
SetUpgradeModeAction.INSTANCE,
PutDataFrameAnalyticsAction.INSTANCE,
GetDataFrameAnalyticsAction.INSTANCE,
Expand Down Expand Up @@ -408,7 +407,9 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
// Async Search
SubmitAsyncSearchAction.INSTANCE,
GetAsyncSearchAction.INSTANCE,
DeleteAsyncResultAction.INSTANCE
DeleteAsyncResultAction.INSTANCE,
// Text Structure
FindFileStructureAction.INSTANCE
));

// rollupV2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.action;
package org.elasticsearch.xpack.core.textstructure.action;

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
Expand All @@ -18,7 +18,7 @@
import org.elasticsearch.common.xcontent.StatusToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructure;
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructure;

import java.io.IOException;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.filestructurefinder;
package org.elasticsearch.xpack.core.textstructure.structurefinder;

import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.filestructurefinder;
package org.elasticsearch.xpack.core.textstructure.structurefinder;

import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
Expand All @@ -25,7 +25,7 @@
import java.util.TreeMap;

/**
* Stores the file format determined by Machine Learning.
* Stores the determined file format.
*/
public class FileStructure implements ToXContentObject, Writeable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.action;
package org.elasticsearch.xpack.core.textstructure.action;

import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.test.AbstractWireSerializingTestCase;
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructure;
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructure;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.action;
package org.elasticsearch.xpack.core.textstructure.action;

import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.test.AbstractWireSerializingTestCase;
import org.elasticsearch.xpack.core.ml.filestructurefinder.FileStructureTests;
import org.elasticsearch.xpack.core.textstructure.action.FindFileStructureAction;
import org.elasticsearch.xpack.core.textstructure.structurefinder.FileStructureTests;

public class FindFileStructureActionResponseTests extends AbstractWireSerializingTestCase<FindFileStructureAction.Response> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.filestructurefinder;
package org.elasticsearch.xpack.core.textstructure.structurefinder;

import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.ml.filestructurefinder;
package org.elasticsearch.xpack.core.textstructure.structurefinder;

import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ToXContent;
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugin/ml/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ dependencies {

// ml deps
api project(':libs:elasticsearch-grok')
api "com.ibm.icu:icu4j:${versions.icu4j}"
api "net.sf.supercsv:super-csv:${versions.supercsv}"
nativeBundle("org.elasticsearch.ml:ml-cpp:${project.version}@zip") {
changing = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
import org.elasticsearch.xpack.core.ml.action.EvaluateDataFrameAction;
import org.elasticsearch.xpack.core.ml.action.ExplainDataFrameAnalyticsAction;
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
import org.elasticsearch.xpack.core.ml.action.FindFileStructureAction;
import org.elasticsearch.xpack.core.ml.action.FlushJobAction;
import org.elasticsearch.xpack.core.ml.action.ForecastJobAction;
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
Expand Down Expand Up @@ -173,7 +172,6 @@
import org.elasticsearch.xpack.ml.action.TransportEvaluateDataFrameAction;
import org.elasticsearch.xpack.ml.action.TransportExplainDataFrameAnalyticsAction;
import org.elasticsearch.xpack.ml.action.TransportFinalizeJobExecutionAction;
import org.elasticsearch.xpack.ml.action.TransportFindFileStructureAction;
import org.elasticsearch.xpack.ml.action.TransportFlushJobAction;
import org.elasticsearch.xpack.ml.action.TransportForecastJobAction;
import org.elasticsearch.xpack.ml.action.TransportGetBucketsAction;
Expand Down Expand Up @@ -279,7 +277,6 @@
import org.elasticsearch.xpack.ml.process.NativeController;
import org.elasticsearch.xpack.ml.process.NativeStorageProvider;
import org.elasticsearch.xpack.ml.rest.RestDeleteExpiredDataAction;
import org.elasticsearch.xpack.ml.rest.RestFindFileStructureAction;
import org.elasticsearch.xpack.ml.rest.RestMlInfoAction;
import org.elasticsearch.xpack.ml.rest.RestSetUpgradeModeAction;
import org.elasticsearch.xpack.ml.rest.calendar.RestDeleteCalendarAction;
Expand Down Expand Up @@ -922,7 +919,6 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
new RestPutCalendarJobAction(),
new RestGetCalendarEventsAction(),
new RestPostCalendarEventAction(),
new RestFindFileStructureAction(),
new RestSetUpgradeModeAction(),
new RestGetDataFrameAnalyticsAction(),
new RestGetDataFrameAnalyticsStatsAction(),
Expand Down Expand Up @@ -1005,7 +1001,6 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
new ActionHandler<>(GetCalendarEventsAction.INSTANCE, TransportGetCalendarEventsAction.class),
new ActionHandler<>(PostCalendarEventsAction.INSTANCE, TransportPostCalendarEventsAction.class),
new ActionHandler<>(PersistJobAction.INSTANCE, TransportPersistJobAction.class),
new ActionHandler<>(FindFileStructureAction.INSTANCE, TransportFindFileStructureAction.class),
new ActionHandler<>(SetUpgradeModeAction.INSTANCE, TransportSetUpgradeModeAction.class),
new ActionHandler<>(GetDataFrameAnalyticsAction.INSTANCE, TransportGetDataFrameAnalyticsAction.class),
new ActionHandler<>(GetDataFrameAnalyticsStatsAction.INSTANCE, TransportGetDataFrameAnalyticsStatsAction.class),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ml.find_file_structure":{
"text_structure.find_structure":{
Copy link
Member Author

Choose a reason for hiding this comment

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

opted to not keep the old yaml definition (with deprecation) as the API was experimental.

"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html",
"description":"Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch."
Expand All @@ -13,7 +13,7 @@
"url":{
"paths":[
{
"path":"/_ml/find_file_structure",
"path":"/_text_structure/find_structure",
"methods":[
"POST"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setup:
# This is to stop the usual content type randomization, which
# would obviously ruin the results for this particular test
Content-Type: "application/json"
ml.find_file_structure:
text_structure.find_structure:
lines_to_sample: 3
line_merge_size_limit: 1234
timeout: 10s
Expand Down Expand Up @@ -67,7 +67,7 @@ setup:
# This is to stop the usual content type randomization, which
# would obviously ruin the results for this particular test
Content-Type: "application/json"
ml.find_file_structure:
text_structure.find_structure:
charset: UTF-8
format: ndjson
timestamp_field: time
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugin/text-structure/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apply plugin: 'elasticsearch.esplugin'
esplugin {
name 'x-pack-text-structure'
description 'Elasticsearch Expanded Pack Plugin - Text Structure'
classname 'org.elasticsearch.xpack.textstructure.TextStructurePlugin'
extendedPlugins = ['x-pack-core']
}
archivesBaseName = 'x-pack-text-structure'

dependencies {
compileOnly project(path: xpackModule('core'), configuration: 'default')
testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts')
api project(':libs:elasticsearch-grok')
api "com.ibm.icu:icu4j:${versions.icu4j}"
api "net.sf.supercsv:super-csv:${versions.supercsv}"
}

addQaCheckDependencies()

tasks.named("testingConventions").configure { enabled = false }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
017f8708c929029dde48bc298deaf3c7ae2452d3
Loading