Skip to content

Add enrich processor #48039

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

Merged
merged 165 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
35af474
first commit
martijnvg Apr 3, 2019
0ae4546
Merge remote-tracking branch 'es/master' into enrich
martijnvg Apr 9, 2019
c905559
Fixed build issue after merge
martijnvg Apr 9, 2019
018b1e2
Merge remote-tracking branch 'es/master' into enrich
martijnvg Apr 12, 2019
7ea14fd
Added enrich policy definition. (#41003)
martijnvg Apr 12, 2019
def1024
Move the policy class to xpack core module. (#41311)
martijnvg Apr 17, 2019
2e9e480
Merge remote-tracking branch 'upstream/master' into enrich
hub-cap Apr 22, 2019
6dc41a8
Refactor the enrich store to remove it from guice (#41421)
hub-cap Apr 23, 2019
ba32255
Merge remote-tracking branch 'upstream/master' into enrich
hub-cap Apr 24, 2019
284c508
Expose Engine.Searcher provider to ingest plugins. (#41010)
martijnvg Apr 24, 2019
1c28f30
Add enrich policy PUT API (#41383)
hub-cap Apr 25, 2019
9f51137
Add enrich qa module for rest tests and (#41568)
martijnvg Apr 26, 2019
8c8e3e0
Merge remote-tracking branch 'es/master' into enrich
martijnvg Apr 29, 2019
3c7f463
Add enrich processor (#41532)
martijnvg Apr 30, 2019
c999c09
Add enrich policy list API (#41553)
hub-cap May 1, 2019
50f3177
Merge remote-tracking branch 'es/master' into enrich
martijnvg May 2, 2019
593a1c1
comment out part of test until delete policy api had been added
martijnvg May 2, 2019
83617e8
Add enrich policy DELETE API (#41495)
hub-cap May 2, 2019
a451292
Add enrich policy runner (#41088)
jbaiera May 2, 2019
33fddef
Change policy runner to use helper method on EnrichPolicy instead of …
martijnvg May 7, 2019
ecffd73
Rename enrich policy index_pattern field to indices. (#41836)
martijnvg May 7, 2019
0bf0f52
Change the reindex fetch in policy runner from 1000 to 10000 and (#41…
martijnvg May 7, 2019
5a02999
Merge remote-tracking branch 'upstream/master' into enrich
hub-cap May 8, 2019
97d658e
Merge remote-tracking branch 'es/master' into enrich
martijnvg May 9, 2019
28c529f
Enrich store should only update the policies via an update task. (#41…
martijnvg May 9, 2019
b65513e
Keep track of the enrich key field in the enrich index. (#42022)
martijnvg May 9, 2019
4ebee27
Tidy up EnrichPolicy class (#41877)
martijnvg May 12, 2019
df3a3f3
Merge remote-tracking branch 'es/master' into enrich
martijnvg May 20, 2019
4dde9e0
Merge branch 'master' into enrich
hub-cap May 21, 2019
ceab8ee
Remove schedule field from EnrichPolicy (#42143)
martijnvg May 22, 2019
833c9d1
Add enrich policy execute API (#41762)
hub-cap May 22, 2019
e6662be
Add step to forcemerge enrich index after reindex (#41969)
jbaiera May 22, 2019
f577ca0
Complete EnrichIT by using the execute enrich policy API (#42433)
martijnvg May 24, 2019
74cb4d5
Merge remote-tracking branch 'es/master' into enrich
martijnvg May 24, 2019
719eebe
Merge remote-tracking branch 'es/master' into enrich
martijnvg May 27, 2019
8747916
Stricter update dependency between pipelines and components used by p…
martijnvg May 28, 2019
55f80ae
Add enrich policy GET API (#41384)
hub-cap May 28, 2019
a90b571
Merge branch 'master' into enrich
hub-cap May 28, 2019
1f3e298
Merge branch 'master' into enrich
jbaiera May 30, 2019
8a1173d
Enrich validate nested mappings (#42452)
jbaiera Jun 3, 2019
1b95434
Limit a enrich policy execution to only one at a time (#42535)
jbaiera Jun 10, 2019
160a5bc
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jun 13, 2019
ce33c44
Changes required for merging in master branch.
martijnvg Jun 13, 2019
3d5515d
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jun 20, 2019
9aed546
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jun 21, 2019
4d03356
Add role for enrich processor (#42677)
hub-cap Jun 24, 2019
5c3368a
Set enrich indices to be read only before swapping their aliases (#42…
jbaiera Jun 24, 2019
ed3bacc
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jun 25, 2019
837999e
Fixed compile errors after merge.
martijnvg Jun 25, 2019
66b7472
Added multi node enrich tests and fixed serialization issues. (#43386)
martijnvg Jun 25, 2019
a743be2
forgot to overwrite getResponseReader(...) method
martijnvg Jun 25, 2019
9ed7f5a
List.of(...) everywhere
martijnvg Jun 25, 2019
8cbe6f6
Make enrich processor use search action through a client (#43311)
jbaiera Jun 25, 2019
b90bae1
unmuted test
martijnvg Jun 25, 2019
8fc3b06
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jun 27, 2019
eac98e9
required changed after merge
martijnvg Jun 27, 2019
813bf4c
Set auto expand replicas on enrich index after force merge is done. (…
jbaiera Jun 28, 2019
8d884d7
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jun 30, 2019
79ba94f
changes required after merge
martijnvg Jun 30, 2019
7c42cde
Make ingest executing non blocking (#43361)
martijnvg Jul 1, 2019
455cbb6
Add restart node enrich tests. (#43579)
martijnvg Jul 1, 2019
b948d31
Validate read priv of enrich source indices (#43595)
hub-cap Jul 1, 2019
ed399b8
Fix restart test
hub-cap Jul 1, 2019
355fe6d
Add enrich coordinator proxy action (#43801)
martijnvg Jul 3, 2019
ad98f68
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jul 4, 2019
9fcb4bb
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jul 4, 2019
002810a
take into account `manage_enrich` builtin role
martijnvg Jul 4, 2019
3fb32c3
added a basic test that enriching data works
martijnvg Jul 4, 2019
34b6067
take builtin role into account in docs tests
martijnvg Jul 5, 2019
b1c9c5c
Ensure enrich policy is immutable (#43604)
hub-cap Jul 11, 2019
c7ba91b
Add Enrich index background task to cleanup old indices (#43746)
jbaiera Jul 17, 2019
49377b0
Add soft limit for max concurrent policy executions (#43117)
jbaiera Jul 23, 2019
9875e16
Merge branch 'master' into enrich
jbaiera Jul 25, 2019
d0a1657
Fix build errors (#44933)
jbaiera Jul 29, 2019
5d0b71c
Merge remote-tracking branch 'es/master' into enrich
martijnvg Jul 29, 2019
6d8bba6
changes required after merge
martijnvg Jul 29, 2019
814c2bb
use LocalStateEnrich.class instead of XPackPlugin.class, EnrichPlugin…
martijnvg Jul 29, 2019
97d3e30
removed unused imports
martijnvg Jul 29, 2019
a8c7a29
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 1, 2019
da3c34c
required change after merge
martijnvg Aug 1, 2019
4c860c0
Add support for overwrite parameter in the enrich processor. (#45029)
martijnvg Aug 8, 2019
6e33080
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 8, 2019
eea64ff
required changes after merge
martijnvg Aug 8, 2019
ccf30c3
Added a custom api to perform the msearch more efficiently for enrich…
martijnvg Aug 9, 2019
43b23aa
Added HLRC support for enrich put policy API. (#45183)
martijnvg Aug 9, 2019
75a6a99
Add support for a more compact enrich values format (#45033)
martijnvg Aug 9, 2019
bfa25b4
Add initial version of enrich processor docs. (#45084)
martijnvg Aug 12, 2019
d775277
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 13, 2019
8adb39e
required changes after merging in upstream branch
martijnvg Aug 13, 2019
4ea8812
Validate policy name like an index name. (#45452)
martijnvg Aug 13, 2019
2559998
Improve naming of enrich policy fields. (#45494)
martijnvg Aug 14, 2019
9e22fd4
Fail delete policy if pipeline exists (#44438)
hub-cap Aug 14, 2019
8b3d358
Fix test broken by policy rename
hub-cap Aug 14, 2019
ae4bfe9
Fix policy removal bug in delete policy (#45573)
hub-cap Aug 15, 2019
d408b79
Prevent delete policy for active executing policy (#45472)
hub-cap Aug 15, 2019
5707bc7
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 16, 2019
ac0e5c9
adjusted enrich rest specs to new format
martijnvg Aug 16, 2019
a7c5925
Consolidate enrich list all and get by name APIs (#45705)
hub-cap Aug 20, 2019
b4e3614
Renamed CoordinatorProxyAction to EnrichCoordinatorProxyAction and (#…
martijnvg Aug 20, 2019
ae83375
ensure that the items in the bulk response are the same as is in the …
martijnvg Aug 21, 2019
a6917a1
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 21, 2019
2879e67
Enrich processor configuration changes (#45466)
martijnvg Aug 22, 2019
b48784f
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 23, 2019
f14874c
Change how type is stored in an enrich policy. (#45789)
martijnvg Aug 23, 2019
3e3cd72
Decouple enrich processor factory from enrich policy (#45826)
martijnvg Aug 23, 2019
1c4ffd3
Remove enrich indices on delete policy (#45870)
hub-cap Aug 23, 2019
a1e8194
Add HLRC support for delete policy api (#45833)
martijnvg Aug 26, 2019
c8436a7
Merge remote-tracking branch 'es/master' into enrich
martijnvg Aug 28, 2019
a815d8d
fixed method signature
martijnvg Aug 28, 2019
63fe69f
Merge remote-tracking branch 'es/master' into enrich
martijnvg Sep 2, 2019
90994ce
removed redundant cast
martijnvg Sep 4, 2019
43ede36
Change exact match processor to match processor. (#46041)
martijnvg Sep 4, 2019
dace374
[DOCS] Separate Enrich API Docs (#46286)
jrodewig Sep 4, 2019
f97cc7f
Merge remote-tracking branch 'es/master' into enrich
martijnvg Sep 9, 2019
a97ed3e
[DOCS] Update "Enrich your data" tutorials (#46417)
jrodewig Sep 9, 2019
d5a9527
Ensure enrich executes on master node only (#46448)
hub-cap Sep 10, 2019
53b19af
Allow comma separated ids in get enrich policy API (#46351)
hub-cap Sep 10, 2019
f1ba62a
Disable default features that are not needed for enrich indices. (#46…
martijnvg Sep 11, 2019
4875c48
fixed typo
martijnvg Sep 11, 2019
eeba099
Convert enrich qa modules to use testclusters.
martijnvg Sep 11, 2019
5345274
Add enrich stats api (#46462)
martijnvg Sep 11, 2019
5d76d2d
Add HLRC support for enrich get policy API. (#45970)
martijnvg Sep 11, 2019
2b95e6a
[DOCS] Reformat enrich stats API (#46600)
jrodewig Sep 11, 2019
2fbaf32
[DOCS] Change // CONSOLE comments to [source,console] (#46669)
jrodewig Sep 12, 2019
a18b587
[DOCS] Correct `<enrich-policy>` parm description for comma-sep list …
jrodewig Sep 18, 2019
e8ffcd7
Add the cluster version to enrich policies (#45021)
jbaiera Sep 20, 2019
afc16ba
Merge remote-tracking branch 'es/master' into enrich
martijnvg Sep 23, 2019
92f24c9
fixed compile errors after merging
martijnvg Sep 23, 2019
1118da0
fixed tests
martijnvg Sep 23, 2019
2d77751
[DOCS] Minor editorial changes to enrich docs
jrodewig Sep 23, 2019
88a1cd5
Add notice to Enrich index mapping metadata (#45996)
jbaiera Sep 24, 2019
d5cf383
Add pipeline to ensure unique Enrich index documents (#46348)
jbaiera Sep 24, 2019
31cfd57
Expose enrich stats api to monitoring. (#46708)
martijnvg Sep 26, 2019
f676d97
Merge remote-tracking branch 'es/master' into enrich
martijnvg Sep 27, 2019
500585a
required changes after merging in master
martijnvg Sep 27, 2019
69cad3d
put provided argument on the previous line just like in master branch,
martijnvg Sep 27, 2019
82c8f16
give monitoring more time
martijnvg Sep 30, 2019
197c1d5
Merge remote-tracking branch 'es/master' into enrich
martijnvg Sep 30, 2019
c3561e8
fixed checkstyle violation
martijnvg Sep 30, 2019
a23c7af
Add config namespace in get policy api response (#47162)
martijnvg Sep 30, 2019
5a213ac
Add enable checks to missing enrich plugin methods (#47187)
hub-cap Oct 1, 2019
5eb9a04
Add retry to force merge operation in EnrichPolicyRunner (#47178)
jbaiera Oct 4, 2019
4d3f681
Merge remote-tracking branch 'elastic/master' into enrich
talevy Oct 4, 2019
c20fa4d
Geo-Match Enrich Processor (#47243)
talevy Oct 7, 2019
3eb07f5
Don't remove indices to avoid monitoring from intermittently failing
martijnvg Oct 8, 2019
957f0fa
Merge remote-tracking branch 'es/master' into enrich
martijnvg Oct 9, 2019
81e6034
change required after merging in master
martijnvg Oct 9, 2019
17eef81
[DOCS] Add docs for `geo_match` enrich policy type (#47745)
jrodewig Oct 9, 2019
f7c03ad
Reuse OperationRouting#searchShards(...) to select local enrich shard…
martijnvg Oct 9, 2019
9e5e51b
Add basic task support for executing enrich policies (#47523)
jbaiera Oct 9, 2019
498789b
match processor should handler values other than string properly (#47…
martijnvg Oct 10, 2019
0caca2f
Add HLRC support for enrich stats API (#47306)
martijnvg Oct 10, 2019
4de7133
Merge remote-tracking branch 'es/master' into enrich
martijnvg Oct 10, 2019
abdbd84
Merge remote-tracking branch 'es/master' into enrich
martijnvg Oct 10, 2019
e06598b
Merge remote-tracking branch 'es/master' into enrich
martijnvg Oct 14, 2019
0ef3668
Remove _type argument from IngestDocument after merging in master
martijnvg Oct 14, 2019
6ed7d69
Add HLRC support for enrich execute policy API (#47991)
martijnvg Oct 14, 2019
ddf3bc2
Change how `max_matches` affects `target_field` option. (#47982)
martijnvg Oct 14, 2019
b0ccce2
Add wait for completion for Enrich policy execution (#47886)
jbaiera Oct 14, 2019
382f264
Fix broken test
jbaiera Oct 14, 2019
7d68935
Fixed test, take into account that Map can be the result if max_match…
martijnvg Oct 15, 2019
6b0cfb5
remove eclipse conditional
martijnvg Oct 15, 2019
85ad27e
Merge remote-tracking branch 'es/master' into enrich
martijnvg Oct 15, 2019
1fcadbb
adjusted minimal supported version
martijnvg Oct 15, 2019
d941e1b
fixed invalid reference
martijnvg Oct 15, 2019
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.client;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.core.AcknowledgedResponse;
import org.elasticsearch.client.enrich.DeletePolicyRequest;
import org.elasticsearch.client.enrich.ExecutePolicyRequest;
import org.elasticsearch.client.enrich.ExecutePolicyResponse;
import org.elasticsearch.client.enrich.GetPolicyRequest;
import org.elasticsearch.client.enrich.GetPolicyResponse;
import org.elasticsearch.client.enrich.PutPolicyRequest;
import org.elasticsearch.client.enrich.StatsRequest;
import org.elasticsearch.client.enrich.StatsResponse;

import java.io.IOException;
import java.util.Collections;

/**
* A wrapper for the {@link RestHighLevelClient} that provides methods for
* accessing the Elastic enrich related methods
* <p>
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-processor.html#enrich-policy-apis">
* X-Pack Enrich Policy APIs on elastic.co</a> for more information.
*/
public final class EnrichClient {

private final RestHighLevelClient restHighLevelClient;

EnrichClient(RestHighLevelClient restHighLevelClient) {
this.restHighLevelClient = restHighLevelClient;
}

/**
* Executes the put policy api, which stores an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#put-policy-api">
* the docs</a> for more.
*
* @param request the {@link PutPolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public AcknowledgedResponse putPolicy(PutPolicyRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
EnrichRequestConverters::putPolicy,
options,
AcknowledgedResponse::fromXContent,
Collections.emptySet()
);
}

/**
* Asynchronously executes the put policy api, which stores an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/enrich-policy-apis.html#put-policy-api">
* the docs</a> for more.
*
* @param request the {@link PutPolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable putPolicyAsync(PutPolicyRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
EnrichRequestConverters::putPolicy,
options,
AcknowledgedResponse::fromXContent,
listener,
Collections.emptySet()
);
}

/**
* Executes the delete policy api, which deletes an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#delete-policy-api">
* the docs</a> for more.
*
* @param request the {@link DeletePolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public AcknowledgedResponse deletePolicy(DeletePolicyRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
EnrichRequestConverters::deletePolicy,
options,
AcknowledgedResponse::fromXContent,
Collections.emptySet()
);
}

/**
* Asynchronously executes the delete policy api, which deletes an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#delete-policy-api">
* the docs</a> for more.
*
* @param request the {@link DeletePolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable deletePolicyAsync(DeletePolicyRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
EnrichRequestConverters::deletePolicy,
options,
AcknowledgedResponse::fromXContent,
listener,
Collections.emptySet()
);
}

/**
* Executes the get policy api, which retrieves an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#get-policy-api">
* the docs</a> for more.
*
* @param request the {@link PutPolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public GetPolicyResponse getPolicy(GetPolicyRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
EnrichRequestConverters::getPolicy,
options,
GetPolicyResponse::fromXContent,
Collections.emptySet()
);
}

/**
* Asynchronously executes the get policy api, which retrieves an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#get-policy-api">
* the docs</a> for more.
*
* @param request the {@link PutPolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable getPolicyAsync(GetPolicyRequest request,
RequestOptions options,
ActionListener<GetPolicyResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
EnrichRequestConverters::getPolicy,
options,
GetPolicyResponse::fromXContent,
listener,
Collections.emptySet()
);
}

/**
* Executes the enrich stats api, which retrieves enrich related stats.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#stats-api">
* the docs</a> for more.
*
* @param request the {@link StatsRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public StatsResponse stats(StatsRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
EnrichRequestConverters::stats,
options,
StatsResponse::fromXContent,
Collections.emptySet()
);
}

/**
* Asynchronously executes the enrich stats api, which retrieves enrich related stats.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#stats-api">
* the docs</a> for more.
*
* @param request the {@link StatsRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable statsAsync(StatsRequest request,
RequestOptions options,
ActionListener<StatsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
EnrichRequestConverters::stats,
options,
StatsResponse::fromXContent,
listener,
Collections.emptySet()
);
}

/**
* Executes the execute policy api, which executes an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#execute-policy">
* the docs</a> for more.
*
* @param request the {@link ExecutePolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public ExecutePolicyResponse executePolicy(ExecutePolicyRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
EnrichRequestConverters::executePolicy,
options,
ExecutePolicyResponse::fromXContent,
Collections.emptySet()
);
}

/**
* Asynchronously executes the execute policy api, which executes an enrich policy.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-policy-apis.html#execute-policy">
* the docs</a> for more.
*
* @param request the {@link ExecutePolicyRequest}
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable executePolicyAsync(ExecutePolicyRequest request,
RequestOptions options,
ActionListener<ExecutePolicyResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
EnrichRequestConverters::executePolicy,
options,
ExecutePolicyResponse::fromXContent,
listener,
Collections.emptySet()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.client;

import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.elasticsearch.client.enrich.DeletePolicyRequest;
import org.elasticsearch.client.enrich.ExecutePolicyRequest;
import org.elasticsearch.client.enrich.GetPolicyRequest;
import org.elasticsearch.client.enrich.PutPolicyRequest;
import org.elasticsearch.client.enrich.StatsRequest;

import java.io.IOException;

import static org.elasticsearch.client.RequestConverters.REQUEST_BODY_CONTENT_TYPE;
import static org.elasticsearch.client.RequestConverters.createEntity;

final class EnrichRequestConverters {

static Request putPolicy(PutPolicyRequest putPolicyRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_enrich", "policy")
.addPathPart(putPolicyRequest.getName())
.build();
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
request.setEntity(createEntity(putPolicyRequest, REQUEST_BODY_CONTENT_TYPE));
return request;
}

static Request deletePolicy(DeletePolicyRequest deletePolicyRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_enrich", "policy")
.addPathPart(deletePolicyRequest.getName())
.build();
return new Request(HttpDelete.METHOD_NAME, endpoint);
}

static Request getPolicy(GetPolicyRequest getPolicyRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_enrich", "policy")
.addCommaSeparatedPathParts(getPolicyRequest.getNames())
.build();
return new Request(HttpGet.METHOD_NAME, endpoint);
}

static Request stats(StatsRequest statsRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_enrich", "_stats")
.build();
return new Request(HttpGet.METHOD_NAME, endpoint);
}

static Request executePolicy(ExecutePolicyRequest executePolicyRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_enrich", "policy")
.addPathPart(executePolicyRequest.getName())
.addPathPartAsIs("_execute")
.build();
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
if (executePolicyRequest.getWaitForCompletion() != null) {
request.addParameter("wait_for_completion", executePolicyRequest.getWaitForCompletion().toString());
}
return request;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public class RestHighLevelClient implements Closeable {
private final RollupClient rollupClient = new RollupClient(this);
private final CcrClient ccrClient = new CcrClient(this);
private final TransformClient transformClient = new TransformClient(this);
private final EnrichClient enrichClient = new EnrichClient(this);

/**
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
Expand Down Expand Up @@ -481,6 +482,10 @@ public TransformClient transform() {
return transformClient;
}

public EnrichClient enrich() {
return enrichClient;
}

/**
* Executes a bulk request using the Bulk API.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">Bulk API on elastic.co</a>
Expand Down
Loading