|
|
@@ -6,8 +6,8 @@
|
|
|
package org.elasticsearch.xpack.ml.integration;
|
|
|
|
|
|
import com.google.common.collect.Ordering;
|
|
|
-import org.apache.lucene.util.LuceneTestCase;
|
|
|
import org.elasticsearch.ElasticsearchStatusException;
|
|
|
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
|
|
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
|
|
import org.elasticsearch.action.bulk.BulkResponse;
|
|
|
import org.elasticsearch.action.get.GetResponse;
|
|
|
@@ -39,7 +39,6 @@ import static org.hamcrest.Matchers.is;
|
|
|
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
|
|
import static org.hamcrest.Matchers.startsWith;
|
|
|
|
|
|
-@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48085")
|
|
|
public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
|
|
|
private static final String BOOLEAN_FIELD = "boolean-field";
|
|
|
@@ -74,6 +73,7 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
startAnalytics(jobId);
|
|
|
waitUntilAnalyticsIsStopped(jobId);
|
|
|
|
|
|
+ client().admin().indices().refresh(new RefreshRequest(destIndex));
|
|
|
SearchResponse sourceData = client().prepareSearch(sourceIndex).setTrackTotalHits(true).setSize(1000).get();
|
|
|
for (SearchHit hit : sourceData.getHits()) {
|
|
|
Map<String, Object> destDoc = getDestDoc(config, hit);
|
|
|
@@ -95,7 +95,8 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
"Started analytics",
|
|
|
"Creating destination index [" + destIndex + "]",
|
|
|
"Finished reindexing to destination index [" + destIndex + "]",
|
|
|
- "Finished analysis");
|
|
|
+ "Finished analysis",
|
|
|
+ "Stored trained model with id");
|
|
|
}
|
|
|
|
|
|
public void testWithOnlyTrainingRowsAndTrainingPercentIsHundred() throws Exception {
|
|
|
@@ -112,6 +113,7 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
startAnalytics(jobId);
|
|
|
waitUntilAnalyticsIsStopped(jobId);
|
|
|
|
|
|
+ client().admin().indices().refresh(new RefreshRequest(destIndex));
|
|
|
SearchResponse sourceData = client().prepareSearch(sourceIndex).setTrackTotalHits(true).setSize(1000).get();
|
|
|
for (SearchHit hit : sourceData.getHits()) {
|
|
|
Map<String, Object> resultsObject = getMlResultsObjectFromDestDoc(getDestDoc(config, hit));
|
|
|
@@ -132,7 +134,8 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
"Started analytics",
|
|
|
"Creating destination index [" + destIndex + "]",
|
|
|
"Finished reindexing to destination index [" + destIndex + "]",
|
|
|
- "Finished analysis");
|
|
|
+ "Finished analysis",
|
|
|
+ "Stored trained model with id");
|
|
|
}
|
|
|
|
|
|
public <T> void testWithOnlyTrainingRowsAndTrainingPercentIsFifty(
|
|
|
@@ -159,6 +162,7 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
|
|
|
int trainingRowsCount = 0;
|
|
|
int nonTrainingRowsCount = 0;
|
|
|
+ client().admin().indices().refresh(new RefreshRequest(destIndex));
|
|
|
SearchResponse sourceData = client().prepareSearch(sourceIndex).setTrackTotalHits(true).setSize(1000).get();
|
|
|
for (SearchHit hit : sourceData.getHits()) {
|
|
|
Map<String, Object> resultsObject = getMlResultsObjectFromDestDoc(getDestDoc(config, hit));
|
|
|
@@ -187,7 +191,8 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
"Started analytics",
|
|
|
"Creating destination index [" + destIndex + "]",
|
|
|
"Finished reindexing to destination index [" + destIndex + "]",
|
|
|
- "Finished analysis");
|
|
|
+ "Finished analysis",
|
|
|
+ "Stored trained model with id");
|
|
|
}
|
|
|
|
|
|
public void testWithOnlyTrainingRowsAndTrainingPercentIsFifty_DependentVariableIsKeyword() throws Exception {
|
|
|
@@ -234,6 +239,7 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
startAnalytics(jobId);
|
|
|
waitUntilAnalyticsIsStopped(jobId);
|
|
|
|
|
|
+ client().admin().indices().refresh(new RefreshRequest(destIndex));
|
|
|
SearchResponse sourceData = client().prepareSearch(sourceIndex).setTrackTotalHits(true).setSize(1000).get();
|
|
|
for (SearchHit hit : sourceData.getHits()) {
|
|
|
Map<String, Object> destDoc = getDestDoc(config, hit);
|
|
|
@@ -253,14 +259,18 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
|
|
"Started analytics",
|
|
|
"Creating destination index [" + destIndex + "]",
|
|
|
"Finished reindexing to destination index [" + destIndex + "]",
|
|
|
- "Finished analysis");
|
|
|
+ "Finished analysis",
|
|
|
+ "Stored trained model with id");
|
|
|
}
|
|
|
|
|
|
public void testDependentVariableCardinalityTooHighError() {
|
|
|
initialize("cardinality_too_high");
|
|
|
indexData(sourceIndex, 6, 5, KEYWORD_FIELD);
|
|
|
// Index one more document with a class different than the two already used.
|
|
|
- client().execute(IndexAction.INSTANCE, new IndexRequest(sourceIndex).source(KEYWORD_FIELD, "fox"));
|
|
|
+ client().execute(IndexAction.INSTANCE, new IndexRequest(sourceIndex)
|
|
|
+ .source(KEYWORD_FIELD, "fox")
|
|
|
+ .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE))
|
|
|
+ .actionGet();
|
|
|
|
|
|
DataFrameAnalyticsConfig config = buildAnalytics(jobId, sourceIndex, destIndex, null, new Classification(KEYWORD_FIELD));
|
|
|
registerAnalytics(config);
|