Improve naming of enrich policy fields. (#45494)

Renamed `enrich_key` to `match_field` and
renamed `enrich_values` to `enrich_fields`.

Relates #32789
This commit is contained in:
Martijn van Groningen 2019-08-14 11:44:31 +02:00
parent 452557cf2e
commit 43b8ab607d
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
13 changed files with 85 additions and 85 deletions

View File

@ -39,17 +39,17 @@ public class PutPolicyRequest implements Validatable, ToXContentObject {
static final ParseField TYPE_FIELD = new ParseField("type"); static final ParseField TYPE_FIELD = new ParseField("type");
static final ParseField QUERY_FIELD = new ParseField("query"); static final ParseField QUERY_FIELD = new ParseField("query");
static final ParseField INDICES_FIELD = new ParseField("indices"); static final ParseField INDICES_FIELD = new ParseField("indices");
static final ParseField ENRICH_KEY_FIELD = new ParseField("enrich_key"); static final ParseField MATCH_FIELD_FIELD = new ParseField("match_field");
static final ParseField ENRICH_VALUES_FIELD = new ParseField("enrich_values"); static final ParseField ENRICH_FIELDS_FIELD = new ParseField("enrich_fields");
private final String name; private final String name;
private final String type; private final String type;
private BytesReference query; private BytesReference query;
private final List<String> indices; private final List<String> indices;
private final String enrichKey; private final String matchField;
private final List<String> enrichValues; private final List<String> enrichFields;
public PutPolicyRequest(String name, String type, List<String> indices, String enrichKey, List<String> enrichValues) { public PutPolicyRequest(String name, String type, List<String> indices, String matchField, List<String> enrichFields) {
if (Strings.hasLength(name) == false) { if (Strings.hasLength(name) == false) {
throw new IllegalArgumentException("name must be a non-null and non-empty string"); throw new IllegalArgumentException("name must be a non-null and non-empty string");
} }
@ -59,18 +59,18 @@ public class PutPolicyRequest implements Validatable, ToXContentObject {
if (indices == null || indices.isEmpty()) { if (indices == null || indices.isEmpty()) {
throw new IllegalArgumentException("indices must be specified"); throw new IllegalArgumentException("indices must be specified");
} }
if (Strings.hasLength(enrichKey) == false) { if (Strings.hasLength(matchField) == false) {
throw new IllegalArgumentException("enrichKey must be a non-null and non-empty string"); throw new IllegalArgumentException("matchField must be a non-null and non-empty string");
} }
if (enrichValues == null || enrichValues.isEmpty()) { if (enrichFields == null || enrichFields.isEmpty()) {
throw new IllegalArgumentException("enrichValues must be specified"); throw new IllegalArgumentException("enrichFields must be specified");
} }
this.name = name; this.name = name;
this.type = type; this.type = type;
this.indices = indices; this.indices = indices;
this.enrichKey = enrichKey; this.matchField = matchField;
this.enrichValues = enrichValues; this.enrichFields = enrichFields;
} }
public String getName() { public String getName() {
@ -97,12 +97,12 @@ public class PutPolicyRequest implements Validatable, ToXContentObject {
return indices; return indices;
} }
public String getEnrichKey() { public String getMatchField() {
return enrichKey; return matchField;
} }
public List<String> getEnrichValues() { public List<String> getEnrichFields() {
return enrichValues; return enrichFields;
} }
@Override @Override
@ -113,8 +113,8 @@ public class PutPolicyRequest implements Validatable, ToXContentObject {
if (query != null) { if (query != null) {
builder.field(QUERY_FIELD.getPreferredName(), asMap(query, builder.contentType())); builder.field(QUERY_FIELD.getPreferredName(), asMap(query, builder.contentType()));
} }
builder.field(ENRICH_KEY_FIELD.getPreferredName(), enrichKey); builder.field(MATCH_FIELD_FIELD.getPreferredName(), matchField);
builder.field(ENRICH_VALUES_FIELD.getPreferredName(), enrichValues); builder.field(ENRICH_FIELDS_FIELD.getPreferredName(), enrichFields);
builder.endObject(); builder.endObject();
return builder; return builder;
} }
@ -128,13 +128,13 @@ public class PutPolicyRequest implements Validatable, ToXContentObject {
Objects.equals(type, that.type) && Objects.equals(type, that.type) &&
Objects.equals(query, that.query) && Objects.equals(query, that.query) &&
Objects.equals(indices, that.indices) && Objects.equals(indices, that.indices) &&
Objects.equals(enrichKey, that.enrichKey) && Objects.equals(matchField, that.matchField) &&
Objects.equals(enrichValues, that.enrichValues); Objects.equals(enrichFields, that.enrichFields);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name, type, query, indices, enrichKey, enrichValues); return Objects.hash(name, type, query, indices, matchField, enrichFields);
} }
private static BytesReference xContentToBytes(ToXContentObject object) throws IOException { private static BytesReference xContentToBytes(ToXContentObject object) throws IOException {

View File

@ -47,8 +47,8 @@ public class EnrichIT extends ESRestHighLevelClientTestCase {
Map<String, Object> responseBody = toMap(getPolicyResponse); Map<String, Object> responseBody = toMap(getPolicyResponse);
assertThat(responseBody.get("type"), equalTo(putPolicyRequest.getType())); assertThat(responseBody.get("type"), equalTo(putPolicyRequest.getType()));
assertThat(responseBody.get("indices"), equalTo(putPolicyRequest.getIndices())); assertThat(responseBody.get("indices"), equalTo(putPolicyRequest.getIndices()));
assertThat(responseBody.get("enrich_key"), equalTo(putPolicyRequest.getEnrichKey())); assertThat(responseBody.get("match_field"), equalTo(putPolicyRequest.getMatchField()));
assertThat(responseBody.get("enrich_values"), equalTo(putPolicyRequest.getEnrichValues())); assertThat(responseBody.get("enrich_fields"), equalTo(putPolicyRequest.getEnrichFields()));
} }
private static Map<String, Object> toMap(Response response) throws IOException { private static Map<String, Object> toMap(Response response) throws IOException {

View File

@ -41,15 +41,15 @@ public class PutPolicyRequestTests extends AbstractRequestTestCase<PutPolicyRequ
assertThat(request.validate().isPresent(), is(false)); assertThat(request.validate().isPresent(), is(false));
Exception e = expectThrows(IllegalArgumentException.class, Exception e = expectThrows(IllegalArgumentException.class,
() -> new PutPolicyRequest(request.getName(), request.getType(), request.getIndices(), null, request.getEnrichValues())); () -> new PutPolicyRequest(request.getName(), request.getType(), request.getIndices(), null, request.getEnrichFields()));
assertThat(e.getMessage(), containsString("enrichKey must be a non-null and non-empty string")); assertThat(e.getMessage(), containsString("matchField must be a non-null and non-empty string"));
} }
public void testEqualsAndHashcode() { public void testEqualsAndHashcode() {
PutPolicyRequest testInstance = createTestInstance(); PutPolicyRequest testInstance = createTestInstance();
EqualsHashCodeTestUtils.checkEqualsAndHashCode(testInstance, (original) -> { EqualsHashCodeTestUtils.checkEqualsAndHashCode(testInstance, (original) -> {
PutPolicyRequest copy = new PutPolicyRequest(original.getName(), original.getType(), original.getIndices(), PutPolicyRequest copy = new PutPolicyRequest(original.getName(), original.getType(), original.getIndices(),
original.getEnrichKey(), original.getEnrichValues()); original.getMatchField(), original.getEnrichFields());
copy.setQuery(original.getQuery()); copy.setQuery(original.getQuery());
return copy; return copy;
}); });
@ -99,7 +99,7 @@ public class PutPolicyRequestTests extends AbstractRequestTestCase<PutPolicyRequ
} else { } else {
assertThat(serverInstance.getPolicy().getQuery(), nullValue()); assertThat(serverInstance.getPolicy().getQuery(), nullValue());
} }
assertThat(clientTestInstance.getEnrichKey(), equalTo(serverInstance.getPolicy().getEnrichKey())); assertThat(clientTestInstance.getMatchField(), equalTo(serverInstance.getPolicy().getMatchField()));
assertThat(clientTestInstance.getEnrichValues(), equalTo(serverInstance.getPolicy().getEnrichValues())); assertThat(clientTestInstance.getEnrichFields(), equalTo(serverInstance.getPolicy().getEnrichFields()));
} }
} }

View File

@ -813,8 +813,8 @@ The main piece to configure is the enrich policy:
| `type` | yes | - | The policy type. | `type` | yes | - | The policy type.
| `indices` | yes | - | The indices to fetch the data from. | `indices` | yes | - | The indices to fetch the data from.
| `query` | no | `match_all` query | The query to be used to select which documents are included. | `query` | no | `match_all` query | The query to be used to select which documents are included.
| `enrich_key` | yes | - | The field that the enrich processor will query against. | `match_field` | yes | - | The field that will be used to match against an input document.
| `enrich_values` | yes | - | The fields to include in the enrich index. | `enrich_fields` | yes | - | The fields that will be available to enrich the input document.
|====== |======
[[enrich-policy-types]] [[enrich-policy-types]]
@ -859,8 +859,8 @@ PUT /_enrich/policy/users-policy
{ {
"type": "exact_match", "type": "exact_match",
"indices": "users", "indices": "users",
"enrich_key": "email", "match_field": "email",
"enrich_values": ["first_name", "last_name", "address", "city", "zip", "state"] "enrich_fields": ["first_name", "last_name", "address", "city", "zip", "state"]
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE // CONSOLE
@ -986,8 +986,8 @@ PUT /_enrich/policy/my-policy
{ {
"type": "exact_match", "type": "exact_match",
"indices": "users", "indices": "users",
"enrich_key": "email", "match_field": "email",
"enrich_values": ["first_name", "last_name", "address", "city", "zip", "state"] "enrich_fields": ["first_name", "last_name", "address", "city", "zip", "state"]
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE // CONSOLE
@ -1023,8 +1023,8 @@ Response:
{ {
"type": "exact_match", "type": "exact_match",
"indices": ["users"], "indices": ["users"],
"enrich_key": "email", "match_field": "email",
"enrich_values": ["first_name", "last_name", "address", "city", "zip", "state"] "enrich_fields": ["first_name", "last_name", "address", "city", "zip", "state"]
} }
-------------------------------------------------- --------------------------------------------------
// TESTRESPONSE // TESTRESPONSE
@ -1053,8 +1053,8 @@ Response:
"name" : "my-policy", "name" : "my-policy",
"type" : "exact_match", "type" : "exact_match",
"indices" : ["users"], "indices" : ["users"],
"enrich_key" : "email", "match_field" : "email",
"enrich_values" : [ "enrich_fields" : [
"first_name", "first_name",
"last_name", "last_name",
"address", "address",

View File

@ -43,8 +43,8 @@ PUT /_enrich/policy/users-policy
{ {
"type": "exact_match", "type": "exact_match",
"indices": "users", "indices": "users",
"enrich_key": "email", "match_field": "email",
"enrich_values": ["first_name", "last_name", "address", "city", "zip", "state"] "enrich_fields": ["first_name", "last_name", "address", "city", "zip", "state"]
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE // CONSOLE

View File

@ -37,8 +37,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
private static final ParseField TYPE = new ParseField("type"); private static final ParseField TYPE = new ParseField("type");
private static final ParseField QUERY = new ParseField("query"); private static final ParseField QUERY = new ParseField("query");
private static final ParseField INDICES = new ParseField("indices"); private static final ParseField INDICES = new ParseField("indices");
private static final ParseField ENRICH_KEY = new ParseField("enrich_key"); private static final ParseField MATCH_FIELD = new ParseField("match_field");
private static final ParseField ENRICH_VALUES = new ParseField("enrich_values"); private static final ParseField ENRICH_FIELDS = new ParseField("enrich_fields");
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static final ConstructingObjectParser<EnrichPolicy, Void> PARSER = new ConstructingObjectParser<>("policy", private static final ConstructingObjectParser<EnrichPolicy, Void> PARSER = new ConstructingObjectParser<>("policy",
@ -63,8 +63,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
return new QuerySource(BytesReference.bytes(contentBuilder), contentBuilder.contentType()); return new QuerySource(BytesReference.bytes(contentBuilder), contentBuilder.contentType());
}, QUERY); }, QUERY);
parser.declareStringArray(ConstructingObjectParser.constructorArg(), INDICES); parser.declareStringArray(ConstructingObjectParser.constructorArg(), INDICES);
parser.declareString(ConstructingObjectParser.constructorArg(), ENRICH_KEY); parser.declareString(ConstructingObjectParser.constructorArg(), MATCH_FIELD);
parser.declareStringArray(ConstructingObjectParser.constructorArg(), ENRICH_VALUES); parser.declareStringArray(ConstructingObjectParser.constructorArg(), ENRICH_FIELDS);
} }
public static EnrichPolicy fromXContent(XContentParser parser) throws IOException { public static EnrichPolicy fromXContent(XContentParser parser) throws IOException {
@ -74,8 +74,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
private final String type; private final String type;
private final QuerySource query; private final QuerySource query;
private final List<String> indices; private final List<String> indices;
private final String enrichKey; private final String matchField;
private final List<String> enrichValues; private final List<String> enrichFields;
public EnrichPolicy(StreamInput in) throws IOException { public EnrichPolicy(StreamInput in) throws IOException {
this( this(
@ -90,13 +90,13 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
public EnrichPolicy(String type, public EnrichPolicy(String type,
QuerySource query, QuerySource query,
List<String> indices, List<String> indices,
String enrichKey, String matchField,
List<String> enrichValues) { List<String> enrichFields) {
this.type = type; this.type = type;
this.query= query; this.query= query;
this.indices = indices; this.indices = indices;
this.enrichKey = enrichKey; this.matchField = matchField;
this.enrichValues = enrichValues; this.enrichFields = enrichFields;
} }
public String getType() { public String getType() {
@ -111,12 +111,12 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
return indices; return indices;
} }
public String getEnrichKey() { public String getMatchField() {
return enrichKey; return matchField;
} }
public List<String> getEnrichValues() { public List<String> getEnrichFields() {
return enrichValues; return enrichFields;
} }
public static String getBaseName(String policyName) { public static String getBaseName(String policyName) {
@ -128,8 +128,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
out.writeString(type); out.writeString(type);
out.writeOptionalWriteable(query); out.writeOptionalWriteable(query);
out.writeStringCollection(indices); out.writeStringCollection(indices);
out.writeString(enrichKey); out.writeString(matchField);
out.writeStringCollection(enrichValues); out.writeStringCollection(enrichFields);
} }
@Override @Override
@ -139,8 +139,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
builder.field(QUERY.getPreferredName(), query.getQueryAsMap()); builder.field(QUERY.getPreferredName(), query.getQueryAsMap());
} }
builder.array(INDICES.getPreferredName(), indices.toArray(new String[0])); builder.array(INDICES.getPreferredName(), indices.toArray(new String[0]));
builder.field(ENRICH_KEY.getPreferredName(), enrichKey); builder.field(MATCH_FIELD.getPreferredName(), matchField);
builder.array(ENRICH_VALUES.getPreferredName(), enrichValues.toArray(new String[0])); builder.array(ENRICH_FIELDS.getPreferredName(), enrichFields.toArray(new String[0]));
return builder; return builder;
} }
@ -152,8 +152,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
return type.equals(policy.type) && return type.equals(policy.type) &&
Objects.equals(query, policy.query) && Objects.equals(query, policy.query) &&
indices.equals(policy.indices) && indices.equals(policy.indices) &&
enrichKey.equals(policy.enrichKey) && matchField.equals(policy.matchField) &&
enrichValues.equals(policy.enrichValues); enrichFields.equals(policy.enrichFields);
} }
@Override @Override
@ -162,8 +162,8 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
type, type,
query, query,
indices, indices,
enrichKey, matchField,
enrichValues enrichFields
); );
} }

View File

@ -36,8 +36,8 @@ public abstract class CommonEnrichRestTestCase extends ESRestTestCase {
public void testBasicFlow() throws Exception { public void testBasicFlow() throws Exception {
// Create the policy: // Create the policy:
Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy"); Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy");
putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-source-index\"], \"enrich_key\": \"host\", " + putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-source-index\"], \"match_field\": \"host\", " +
"\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"]}"); "\"enrich_fields\": [\"globalRank\", \"tldRank\", \"tld\"]}");
assertOK(client().performRequest(putPolicyRequest)); assertOK(client().performRequest(putPolicyRequest));
// Add entry to source index and then refresh: // Add entry to source index and then refresh:
@ -79,8 +79,8 @@ public abstract class CommonEnrichRestTestCase extends ESRestTestCase {
public void testImmutablePolicy() throws IOException { public void testImmutablePolicy() throws IOException {
Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy"); Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy");
putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-source-index\"], \"enrich_key\": \"host\", " + putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-source-index\"], \"match_field\": \"host\", " +
"\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"]}"); "\"enrich_fields\": [\"globalRank\", \"tldRank\", \"tld\"]}");
assertOK(client().performRequest(putPolicyRequest)); assertOK(client().performRequest(putPolicyRequest));
ResponseException exc = expectThrows(ResponseException.class, () -> client().performRequest(putPolicyRequest)); ResponseException exc = expectThrows(ResponseException.class, () -> client().performRequest(putPolicyRequest));

View File

@ -34,8 +34,8 @@ public class EnrichSecurityFailureIT extends ESRestTestCase {
public void testFailure() { public void testFailure() {
Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy"); Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy");
putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-source-index\"], \"enrich_key\": \"host\", " + putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-source-index\"], \"match_field\": \"host\", " +
"\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"]}"); "\"enrich_fields\": [\"globalRank\", \"tldRank\", \"tld\"]}");
ResponseException exc = expectThrows(ResponseException.class, () -> client().performRequest(putPolicyRequest)); ResponseException exc = expectThrows(ResponseException.class, () -> client().performRequest(putPolicyRequest));
assertTrue(exc.getMessage().contains("action [cluster:admin/xpack/enrich/put] is unauthorized for user [test_enrich_no_privs]")); assertTrue(exc.getMessage().contains("action [cluster:admin/xpack/enrich/put] is unauthorized for user [test_enrich_no_privs]"));
} }

View File

@ -37,8 +37,8 @@ public class EnrichSecurityIT extends CommonEnrichRestTestCase {
// This test is here because it requires a valid user that has permission to execute policy PUTs but should fail if the user // This test is here because it requires a valid user that has permission to execute policy PUTs but should fail if the user
// does not have access to read the backing indices used to enrich the data. // does not have access to read the backing indices used to enrich the data.
Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy"); Request putPolicyRequest = new Request("PUT", "/_enrich/policy/my_policy");
putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"some-other-index\"], \"enrich_key\": \"host\", " + putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"some-other-index\"], \"match_field\": \"host\", " +
"\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"]}"); "\"enrich_fields\": [\"globalRank\", \"tldRank\", \"tld\"]}");
ResponseException exc = expectThrows(ResponseException.class, () -> client().performRequest(putPolicyRequest)); ResponseException exc = expectThrows(ResponseException.class, () -> client().performRequest(putPolicyRequest));
assertThat(exc.getMessage(), assertThat(exc.getMessage(),
containsString("unable to store policy because no indices match with the specified index patterns [some-other-index]")); containsString("unable to store policy because no indices match with the specified index patterns [some-other-index]"));

View File

@ -7,8 +7,8 @@
body: body:
type: exact_match type: exact_match
indices: ["bar*"] indices: ["bar*"]
enrich_key: baz match_field: baz
enrich_values: ["a", "b"] enrich_fields: ["a", "b"]
- is_true: acknowledged - is_true: acknowledged
- do: - do:
@ -21,8 +21,8 @@
name: policy-crud name: policy-crud
- match: { type: exact_match } - match: { type: exact_match }
- match: { indices: ["bar*"] } - match: { indices: ["bar*"] }
- match: { enrich_key: baz } - match: { match_field: baz }
- match: { enrich_values: ["a", "b"] } - match: { enrich_fields: ["a", "b"] }
- do: - do:
enrich.list_policy: {} enrich.list_policy: {}
@ -30,8 +30,8 @@
- match: { policies.0.name: policy-crud } - match: { policies.0.name: policy-crud }
- match: { policies.0.type: exact_match } - match: { policies.0.type: exact_match }
- match: { policies.0.indices: ["bar*"] } - match: { policies.0.indices: ["bar*"] }
- match: { policies.0.enrich_key: baz } - match: { policies.0.match_field: baz }
- match: { policies.0.enrich_values: ["a", "b"] } - match: { policies.0.enrich_fields: ["a", "b"] }
- do: - do:
enrich.delete_policy: enrich.delete_policy:

View File

@ -128,8 +128,8 @@ public class EnrichPolicyRunner implements Runnable {
} }
// Validate the key and values // Validate the key and values
try { try {
validateField(mapping, policy.getEnrichKey(), true); validateField(mapping, policy.getMatchField(), true);
for (String valueFieldName : policy.getEnrichValues()) { for (String valueFieldName : policy.getEnrichFields()) {
validateField(mapping, valueFieldName, false); validateField(mapping, valueFieldName, false);
} }
} catch (ElasticsearchException e) { } catch (ElasticsearchException e) {
@ -210,14 +210,14 @@ public class EnrichPolicyRunner implements Runnable {
.field("enabled", true) .field("enabled", true)
.endObject() .endObject()
.startObject("properties") .startObject("properties")
.startObject(policy.getEnrichKey()) .startObject(policy.getMatchField())
.field("type", keyType) .field("type", keyType)
.field("doc_values", false) .field("doc_values", false)
.endObject() .endObject()
.endObject() .endObject()
.startObject("_meta") .startObject("_meta")
.field(ENRICH_POLICY_FIELD_NAME, policyName) .field(ENRICH_POLICY_FIELD_NAME, policyName)
.field(ENRICH_KEY_FIELD_NAME, policy.getEnrichKey()) .field(ENRICH_KEY_FIELD_NAME, policy.getMatchField())
.endObject() .endObject()
.endObject() .endObject()
.endObject(); .endObject();
@ -254,8 +254,8 @@ public class EnrichPolicyRunner implements Runnable {
logger.debug("Policy [{}]: Transferring source data to new enrich index [{}]", policyName, destinationIndexName); logger.debug("Policy [{}]: Transferring source data to new enrich index [{}]", policyName, destinationIndexName);
// Filter down the source fields to just the ones required by the policy // Filter down the source fields to just the ones required by the policy
final Set<String> retainFields = new HashSet<>(); final Set<String> retainFields = new HashSet<>();
retainFields.add(policy.getEnrichKey()); retainFields.add(policy.getMatchField());
retainFields.addAll(policy.getEnrichValues()); retainFields.addAll(policy.getEnrichFields());
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.size(fetchSize); searchSourceBuilder.size(fetchSize);
searchSourceBuilder.fetchSource(retainFields.toArray(new String[0]), new String[0]); searchSourceBuilder.fetchSource(retainFields.toArray(new String[0]), new String[0]);

View File

@ -35,7 +35,7 @@ final class EnrichProcessorFactory implements Processor.Factory, Consumer<Cluste
throw new IllegalArgumentException("policy [" + policyName + "] does not exists"); throw new IllegalArgumentException("policy [" + policyName + "] does not exists");
} }
String enrichKey = ConfigurationUtils.readStringProperty(TYPE, tag, config, "enrich_key", policy.getEnrichKey()); String enrichKey = ConfigurationUtils.readStringProperty(TYPE, tag, config, "enrich_key", policy.getMatchField());
boolean ignoreMissing = ConfigurationUtils.readBooleanProperty(TYPE, tag, config, "ignore_missing", false); boolean ignoreMissing = ConfigurationUtils.readBooleanProperty(TYPE, tag, config, "ignore_missing", false);
boolean overrideEnabled = ConfigurationUtils.readBooleanProperty(TYPE, tag, config, "override", true); boolean overrideEnabled = ConfigurationUtils.readBooleanProperty(TYPE, tag, config, "override", true);
@ -62,7 +62,7 @@ final class EnrichProcessorFactory implements Processor.Factory, Consumer<Cluste
} }
for (EnrichSpecification specification : specifications) { for (EnrichSpecification specification : specifications) {
if (policy.getEnrichValues().contains(specification.sourceField) == false) { if (policy.getEnrichFields().contains(specification.sourceField) == false) {
throw new IllegalArgumentException("source field [" + specification.sourceField + "] does not exist in policy [" + throw new IllegalArgumentException("source field [" + specification.sourceField + "] does not exist in policy [" +
policyName + "]"); policyName + "]");
} }

View File

@ -89,7 +89,7 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase<EnrichPolicy>
assertThat(expectedInstance.getQuery(), nullValue()); assertThat(expectedInstance.getQuery(), nullValue());
} }
assertThat(newInstance.getIndices(), equalTo(expectedInstance.getIndices())); assertThat(newInstance.getIndices(), equalTo(expectedInstance.getIndices()));
assertThat(newInstance.getEnrichKey(), equalTo(expectedInstance.getEnrichKey())); assertThat(newInstance.getMatchField(), equalTo(expectedInstance.getMatchField()));
assertThat(newInstance.getEnrichValues(), equalTo(expectedInstance.getEnrichValues())); assertThat(newInstance.getEnrichFields(), equalTo(expectedInstance.getEnrichFields()));
} }
} }