Skip to content

Conversation

@dimitris-athanasiou
Copy link
Contributor

We need to disable dynamic mapping to the destination
index of data frame analytics jobs. If the source index
has dynamic mapping disabled, then after reindexing it is
possible that we add mappings for fields that were previously
unmapped, thus making them eligible features. This is
confusing to the user.

This commit disables dynamic mapping to the destination index.
It makes all result field mappings explicit.

We need to disable dynamic mapping to the destination
index of data frame analytics jobs. If the source index
has dynamic mapping disabled, then after reindexing it is
possible that we add mappings for fields that were previously
unmapped, thus making them eligible features. This is
confusing to the user.

This commit disables dynamic mapping to the destination index.
It makes all result field mappings explicit.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (:ml)

Copy link

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

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

LGTM, although I think there is one place where you can make the diagnostics better if a test ever fails in the future

Comment on lines 41 to 46
Map<String, Object> mergedMappingsMap = mergedMappings.getSourceAsMap();
assertThat(mergedMappingsMap.size(), equalTo(2));
assertThat(mergedMappingsMap.containsKey("dynamic"), is(true));
assertThat(mergedMappingsMap.get("dynamic"), equalTo(false));
assertThat(mergedMappingsMap.containsKey("properties"), is(true));
assertThat(mergedMappingsMap.get("properties"), equalTo(index1Mappings.get("properties")));

Choose a reason for hiding this comment

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

If you constructed a map containing the expected contents, then asserted equality with the merged mappings map then you'd get better feedback in the case of failure - both maps would get printed instead of (for example) just finding out that there were 3 items instead of 2.

Copy link
Contributor

@przemekwitek przemekwitek left a comment

Choose a reason for hiding this comment

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

LGTM

Just two nits from my side.

public void testGetResultMappings() {
Map<String, Object> resultMappings = new Regression("foo").getResultMappings("results", null);
assertThat(resultMappings, hasEntry("results.foo_prediction", Collections.singletonMap("type", "double")));
assertThat(resultMappings, hasEntry("results.feature_importance", Regression.FEATURE_IMPORTANCE_MAPPING));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add is_training here?

Map<String, Object> resultMappings =
new Classification("foo").getResultMappings("results", fieldCapabilitiesResponse);

assertThat(resultMappings, hasEntry("results.foo_prediction", singletonMap("type", "dummy")));
Copy link
Contributor

Choose a reason for hiding this comment

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

[optional] An alternative which I sometimes find more readable is:

assertThat(resultMappings, allOf(hasEntry(...), ..., hasEntry(...)));

@dimitris-athanasiou dimitris-athanasiou merged commit e6935d9 into elastic:master Dec 8, 2020
@dimitris-athanasiou dimitris-athanasiou deleted the disable-dynamic-mapping-in-dfa-dest-index branch December 8, 2020 10:10
dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request Dec 8, 2020
We need to disable dynamic mapping to the destination
index of data frame analytics jobs. If the source index
has dynamic mapping disabled, then after reindexing it is
possible that we add mappings for fields that were previously
unmapped, thus making them eligible features. This is
confusing to the user.

This commit disables dynamic mapping to the destination index.
It makes all result field mappings explicit.

Backport of elastic#65972
dimitris-athanasiou added a commit that referenced this pull request Dec 8, 2020
We need to disable dynamic mapping to the destination
index of data frame analytics jobs. If the source index
has dynamic mapping disabled, then after reindexing it is
possible that we add mappings for fields that were previously
unmapped, thus making them eligible features. This is
confusing to the user.

This commit disables dynamic mapping to the destination index.
It makes all result field mappings explicit.

Backport of #65972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants