Remove schedule field from EnrichPolicy (#42143)
This commit is contained in:
parent
323251c3d1
commit
9e514cb161
|
@ -39,7 +39,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
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 ENRICH_KEY = new ParseField("enrich_key");
|
||||||
private static final ParseField ENRICH_VALUES = new ParseField("enrich_values");
|
private static final ParseField ENRICH_VALUES = new ParseField("enrich_values");
|
||||||
private static final ParseField SCHEDULE = new ParseField("schedule");
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static final ConstructingObjectParser<EnrichPolicy, Void> PARSER = new ConstructingObjectParser<>("policy",
|
private static final ConstructingObjectParser<EnrichPolicy, Void> PARSER = new ConstructingObjectParser<>("policy",
|
||||||
|
@ -48,8 +47,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
(QuerySource) args[1],
|
(QuerySource) args[1],
|
||||||
(List<String>) args[2],
|
(List<String>) args[2],
|
||||||
(String) args[3],
|
(String) args[3],
|
||||||
(List<String>) args[4],
|
(List<String>) args[4]
|
||||||
(String) args[5]
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -67,7 +65,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
parser.declareStringArray(ConstructingObjectParser.constructorArg(), INDICES);
|
parser.declareStringArray(ConstructingObjectParser.constructorArg(), INDICES);
|
||||||
parser.declareString(ConstructingObjectParser.constructorArg(), ENRICH_KEY);
|
parser.declareString(ConstructingObjectParser.constructorArg(), ENRICH_KEY);
|
||||||
parser.declareStringArray(ConstructingObjectParser.constructorArg(), ENRICH_VALUES);
|
parser.declareStringArray(ConstructingObjectParser.constructorArg(), ENRICH_VALUES);
|
||||||
parser.declareString(ConstructingObjectParser.constructorArg(), SCHEDULE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnrichPolicy fromXContent(XContentParser parser) throws IOException {
|
public static EnrichPolicy fromXContent(XContentParser parser) throws IOException {
|
||||||
|
@ -79,7 +76,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
private final List<String> indices;
|
private final List<String> indices;
|
||||||
private final String enrichKey;
|
private final String enrichKey;
|
||||||
private final List<String> enrichValues;
|
private final List<String> enrichValues;
|
||||||
private final String schedule;
|
|
||||||
|
|
||||||
public EnrichPolicy(StreamInput in) throws IOException {
|
public EnrichPolicy(StreamInput in) throws IOException {
|
||||||
this(
|
this(
|
||||||
|
@ -87,8 +83,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
in.readOptionalWriteable(QuerySource::new),
|
in.readOptionalWriteable(QuerySource::new),
|
||||||
in.readStringList(),
|
in.readStringList(),
|
||||||
in.readString(),
|
in.readString(),
|
||||||
in.readStringList(),
|
in.readStringList()
|
||||||
in.readString()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,11 +91,9 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
QuerySource query,
|
QuerySource query,
|
||||||
List<String> indices,
|
List<String> indices,
|
||||||
String enrichKey,
|
String enrichKey,
|
||||||
List<String> enrichValues,
|
List<String> enrichValues) {
|
||||||
String schedule) {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.query= query;
|
this.query= query;
|
||||||
this.schedule = schedule;
|
|
||||||
this.indices = indices;
|
this.indices = indices;
|
||||||
this.enrichKey = enrichKey;
|
this.enrichKey = enrichKey;
|
||||||
this.enrichValues = enrichValues;
|
this.enrichValues = enrichValues;
|
||||||
|
@ -126,10 +119,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
return enrichValues;
|
return enrichValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchedule() {
|
|
||||||
return schedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getBaseName(String policyName) {
|
public static String getBaseName(String policyName) {
|
||||||
return ENRICH_INDEX_NAME_BASE + policyName;
|
return ENRICH_INDEX_NAME_BASE + policyName;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +130,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
out.writeStringCollection(indices);
|
out.writeStringCollection(indices);
|
||||||
out.writeString(enrichKey);
|
out.writeString(enrichKey);
|
||||||
out.writeStringCollection(enrichValues);
|
out.writeStringCollection(enrichValues);
|
||||||
out.writeString(schedule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -153,7 +141,6 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
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(ENRICH_KEY.getPreferredName(), enrichKey);
|
||||||
builder.array(ENRICH_VALUES.getPreferredName(), enrichValues.toArray(new String[0]));
|
builder.array(ENRICH_VALUES.getPreferredName(), enrichValues.toArray(new String[0]));
|
||||||
builder.field(SCHEDULE.getPreferredName(), schedule);
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +153,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
Objects.equals(query, policy.query) &&
|
Objects.equals(query, policy.query) &&
|
||||||
indices.equals(policy.indices) &&
|
indices.equals(policy.indices) &&
|
||||||
enrichKey.equals(policy.enrichKey) &&
|
enrichKey.equals(policy.enrichKey) &&
|
||||||
enrichValues.equals(policy.enrichValues) &&
|
enrichValues.equals(policy.enrichValues);
|
||||||
schedule.equals(policy.schedule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,8 +163,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
query,
|
query,
|
||||||
indices,
|
indices,
|
||||||
enrichKey,
|
enrichKey,
|
||||||
enrichValues,
|
enrichValues
|
||||||
schedule
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,8 +229,7 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
|
||||||
(QuerySource) args[2],
|
(QuerySource) args[2],
|
||||||
(List<String>) args[3],
|
(List<String>) args[3],
|
||||||
(String) args[4],
|
(String) args[4],
|
||||||
(List<String>) args[5],
|
(List<String>) args[5])
|
||||||
(String) args[6])
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class EnrichIT extends ESRestTestCase {
|
||||||
// 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-index*\"], \"enrich_key\": \"host\", " +
|
putPolicyRequest.setJsonEntity("{\"type\": \"exact_match\",\"indices\": [\"my-index*\"], \"enrich_key\": \"host\", " +
|
||||||
"\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"], \"schedule\": \"0 5 * * *\"}");
|
"\"enrich_values\": [\"globalRank\", \"tldRank\", \"tld\"]}");
|
||||||
assertOK(client().performRequest(putPolicyRequest));
|
assertOK(client().performRequest(putPolicyRequest));
|
||||||
|
|
||||||
// create index (remove when execute policy api has been added)
|
// create index (remove when execute policy api has been added)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
indices: ["bar*"]
|
indices: ["bar*"]
|
||||||
enrich_key: baz
|
enrich_key: baz
|
||||||
enrich_values: ["a", "b"]
|
enrich_values: ["a", "b"]
|
||||||
schedule: "*/120"
|
|
||||||
- is_true: acknowledged
|
- is_true: acknowledged
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
- match: { policies.0.indices: ["bar*"] }
|
- match: { policies.0.indices: ["bar*"] }
|
||||||
- match: { policies.0.enrich_key: baz }
|
- match: { policies.0.enrich_key: baz }
|
||||||
- match: { policies.0.enrich_values: ["a", "b"] }
|
- match: { policies.0.enrich_values: ["a", "b"] }
|
||||||
- match: { policies.0.schedule: "*/120" }
|
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
enrich.delete_policy:
|
enrich.delete_policy:
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase {
|
||||||
enrichFields.add("field2");
|
enrichFields.add("field2");
|
||||||
enrichFields.add("field5");
|
enrichFields.add("field5");
|
||||||
EnrichPolicy policy =
|
EnrichPolicy policy =
|
||||||
new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndex), "field1", enrichFields, "");
|
new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndex), "field1", enrichFields);
|
||||||
String policyName = "test1";
|
String policyName = "test1";
|
||||||
|
|
||||||
ActionListener<PolicyExecutionResult> listener = new ActionListener<PolicyExecutionResult>() {
|
ActionListener<PolicyExecutionResult> listener = new ActionListener<PolicyExecutionResult>() {
|
||||||
|
@ -204,7 +204,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase {
|
||||||
enrichFields.add("field2");
|
enrichFields.add("field2");
|
||||||
enrichFields.add("field5");
|
enrichFields.add("field5");
|
||||||
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndexPattern),
|
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList(sourceIndexPattern),
|
||||||
"field1", enrichFields, "");
|
"field1", enrichFields);
|
||||||
String policyName = "test1";
|
String policyName = "test1";
|
||||||
|
|
||||||
ActionListener<PolicyExecutionResult> listener = new ActionListener<PolicyExecutionResult>() {
|
ActionListener<PolicyExecutionResult> listener = new ActionListener<PolicyExecutionResult>() {
|
||||||
|
|
|
@ -61,8 +61,7 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase<EnrichPolicy>
|
||||||
randomBoolean() ? querySource : null,
|
randomBoolean() ? querySource : null,
|
||||||
Arrays.asList(generateRandomStringArray(8, 4, false, false)),
|
Arrays.asList(generateRandomStringArray(8, 4, false, false)),
|
||||||
randomAlphaOfLength(4),
|
randomAlphaOfLength(4),
|
||||||
Arrays.asList(generateRandomStringArray(8, 4, false, false)),
|
Arrays.asList(generateRandomStringArray(8, 4, false, false))
|
||||||
randomAlphaOfLength(4)
|
|
||||||
);
|
);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
|
@ -92,6 +91,5 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase<EnrichPolicy>
|
||||||
assertThat(newInstance.getIndices(), equalTo(expectedInstance.getIndices()));
|
assertThat(newInstance.getIndices(), equalTo(expectedInstance.getIndices()));
|
||||||
assertThat(newInstance.getEnrichKey(), equalTo(expectedInstance.getEnrichKey()));
|
assertThat(newInstance.getEnrichKey(), equalTo(expectedInstance.getEnrichKey()));
|
||||||
assertThat(newInstance.getEnrichValues(), equalTo(expectedInstance.getEnrichValues()));
|
assertThat(newInstance.getEnrichValues(), equalTo(expectedInstance.getEnrichValues()));
|
||||||
assertThat(newInstance.getSchedule(), equalTo(expectedInstance.getSchedule()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
|
||||||
public void testCreateProcessorInstance() throws Exception {
|
public void testCreateProcessorInstance() throws Exception {
|
||||||
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
||||||
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key",
|
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key",
|
||||||
enrichValues, "schedule");
|
enrichValues);
|
||||||
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null);
|
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null);
|
||||||
|
|
||||||
Map<String, Object> config = new HashMap<>();
|
Map<String, Object> config = new HashMap<>();
|
||||||
|
@ -105,7 +105,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
|
||||||
public void testPolicyNameMissing() {
|
public void testPolicyNameMissing() {
|
||||||
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
||||||
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key",
|
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key",
|
||||||
enrichValues, "schedule");
|
enrichValues);
|
||||||
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("_name", policy), null);
|
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("_name", policy), null);
|
||||||
|
|
||||||
Map<String, Object> config = new HashMap<>();
|
Map<String, Object> config = new HashMap<>();
|
||||||
|
@ -137,7 +137,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
|
||||||
public void testUnsupportedPolicy() {
|
public void testUnsupportedPolicy() {
|
||||||
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
||||||
EnrichPolicy policy =
|
EnrichPolicy policy =
|
||||||
new EnrichPolicy("unsupported", null, Collections.singletonList("source_index"), "my_key", enrichValues, "schedule");
|
new EnrichPolicy("unsupported", null, Collections.singletonList("source_index"), "my_key", enrichValues);
|
||||||
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null);
|
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null);
|
||||||
|
|
||||||
Map<String, Object> config = new HashMap<>();
|
Map<String, Object> config = new HashMap<>();
|
||||||
|
@ -170,7 +170,7 @@ public class EnrichProcessorFactoryTests extends ESTestCase {
|
||||||
public void testNonExistingDecorateField() throws Exception {
|
public void testNonExistingDecorateField() throws Exception {
|
||||||
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
List<String> enrichValues = Arrays.asList("globalRank", "tldRank", "tld");
|
||||||
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key",
|
EnrichPolicy policy = new EnrichPolicy(EnrichPolicy.EXACT_MATCH_TYPE, null, Collections.singletonList("source_index"), "my_key",
|
||||||
enrichValues, "schedule");
|
enrichValues);
|
||||||
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null);
|
EnrichProcessorFactory factory = new EnrichProcessorFactory(createClusterStateSupplier("majestic", policy), null);
|
||||||
|
|
||||||
Map<String, Object> config = new HashMap<>();
|
Map<String, Object> config = new HashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue