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

Use query in cardinality check #49939

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
addressing pr comments
benwtrent committed Dec 9, 2019
commit d733b6eece89aa5e8ad0769b00117688fc63092e
Original file line number Diff line number Diff line change
@@ -232,7 +232,7 @@ public void testWithOnlyTrainingRowsAndTrainingPercentIsFifty_DependentVariableI
"classification_training_percent_is_50_boolean", BOOLEAN_FIELD, BOOLEAN_FIELD_VALUES, Boolean::valueOf);
}

public void testDependentVariableCardinalityTooHighError() {
public void testDependentVariableCardinalityTooHighError() throws Exception {
initialize("cardinality_too_high");
indexData(sourceIndex, 6, 5, KEYWORD_FIELD);
// Index one more document with a class different than the two already used.
@@ -250,8 +250,8 @@ public void testDependentVariableCardinalityTooHighError() {
assertThat(e.getMessage(), equalTo("Field [keyword-field] must have at most [2] distinct values but there were at least [3]"));
}

public void testDependentVariableCardinalityTooHighErrorButWithQuery() throws Exception {
initialize("cardinality_too_high");
public void testDependentVariableCardinalityTooHighButWithQueryMakesItWithinRange() throws Exception {
initialize("cardinality_too_high_with_query");
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)
Original file line number Diff line number Diff line change
@@ -163,13 +163,8 @@ protected EvaluateDataFrameAction.Response evaluateDataFrame(String index, Evalu
}

protected static DataFrameAnalyticsConfig buildAnalytics(String id, String sourceIndex, String destIndex,
@Nullable String resultsField, DataFrameAnalysis analysis) {
return new DataFrameAnalyticsConfig.Builder()
.setId(id)
.setSource(new DataFrameAnalyticsSource(new String[] { sourceIndex }, null, null))
.setDest(new DataFrameAnalyticsDest(destIndex, resultsField))
.setAnalysis(analysis)
.build();
@Nullable String resultsField, DataFrameAnalysis analysis) throws Exception {
return buildAnalytics(id, sourceIndex, destIndex, resultsField, analysis, QueryBuilders.matchAllQuery());
}

protected static DataFrameAnalyticsConfig buildAnalytics(String id, String sourceIndex, String destIndex,