diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/AbstractEnrichTestCase.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/AbstractEnrichTestCase.java index d53dec93b72..aaed134ded8 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/AbstractEnrichTestCase.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/AbstractEnrichTestCase.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.enrich; import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; +import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; @@ -66,7 +67,11 @@ public abstract class AbstractEnrichTestCase extends ESSingleNodeTestCase { try { client.admin().indices().create(createIndexRequest).actionGet(); } catch (ResourceAlreadyExistsException e) { - // and that is okay + // and that is okay, but update the mapping so that there is always a mapping for match field: + PutMappingRequest putMappingRequest = new PutMappingRequest(sourceIndex); + putMappingRequest.type("_doc"); + putMappingRequest.source(policy.getMatchField(), "type=keyword"); + client.admin().indices().putMapping(putMappingRequest).actionGet(); } } } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportGetEnrichPolicyActionTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportGetEnrichPolicyActionTests.java index fcb0c5a9bb9..79b4844091a 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportGetEnrichPolicyActionTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportGetEnrichPolicyActionTests.java @@ -176,7 +176,8 @@ public class TransportGetEnrichPolicyActionTests extends AbstractEnrichTestCase assertThat(error.get(), nullValue()); // save a second one to verify the count below on GET - error = saveEnrichPolicy("something-else", randomEnrichPolicy(XContentType.JSON), clusterService); + EnrichPolicy policy2 = randomEnrichPolicy(XContentType.JSON); + error = saveEnrichPolicy("something-else", policy2, clusterService); assertThat(error.get(), nullValue()); final CountDownLatch latch = new CountDownLatch(1);