Java Code Examples for org.elasticsearch.client.Client#execute()
The following examples show how to use
org.elasticsearch.client.Client#execute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlushCacheApiAction.java From deprecated-security-advanced-modules with Apache License 2.0 | 5 votes |
@Override protected void handleDelete(RestChannel channel, RestRequest request, Client client, final JsonNode content) throws IOException { client.execute( ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(CType.lcStringValues().toArray(new String[0])), new ActionListener<ConfigUpdateResponse>() { @Override public void onResponse(ConfigUpdateResponse ur) { if(ur.hasFailures()) { log.error("Cannot flush cache due to", ur.failures().get(0)); internalErrorResponse(channel, "Cannot flush cache due to "+ ur.failures().get(0).getMessage()+"."); return; } successResponse(channel, "Cache flushed successfully."); if (log.isDebugEnabled()) { log.debug("cache flushed successfully"); } } @Override public void onFailure(Exception e) { log.error("Cannot flush cache due to", e); internalErrorResponse(channel, "Cannot flush cache due to "+ e.getMessage()+"."); } } ); }
Example 2
Source File: RestStatsAnomalyDetectorAction.java From anomaly-detection with Apache License 2.0 | 5 votes |
/** * Make async request to get the Anomaly Detection statistics from each node and, onResponse, set the * ADStatsNodesResponse field of ADStatsResponse * * @param client Client * @param listener MultiResponsesDelegateActionListener to be used once both requests complete * @param adStatsRequest Request containing stats to be retrieved */ private void getNodeStats( Client client, MultiResponsesDelegateActionListener<ADStatsResponse> listener, ADStatsRequest adStatsRequest ) { client.execute(ADStatsNodesAction.INSTANCE, adStatsRequest, ActionListener.wrap(adStatsResponse -> { ADStatsResponse restADStatsResponse = new ADStatsResponse(); restADStatsResponse.setADStatsNodesResponse(adStatsResponse); listener.onResponse(restADStatsResponse); }, listener::onFailure)); }
Example 3
Source File: ClientUtil.java From anomaly-detection with Apache License 2.0 | 5 votes |
/** * Cancel long running query for given detectorId * @param client Elasticsearch client * @param detectorId Anomaly Detector Id * @param LOG Logger */ private void cancelRunningQuery(Client client, String detectorId, Logger LOG) { ListTasksRequest listTasksRequest = new ListTasksRequest(); listTasksRequest.setActions("*search*"); client .execute( ListTasksAction.INSTANCE, listTasksRequest, ActionListener.wrap(response -> { onListTaskResponse(response, detectorId, LOG); }, exception -> { LOG.error("List Tasks failed.", exception); throw new InternalFailure(detectorId, "Failed to list current tasks", exception); }) ); }
Example 4
Source File: RestCoordinateMultiSearchAction.java From siren-join with GNU Affero General Public License v3.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { MultiSearchRequest multiSearchRequest = new MultiSearchRequest(); String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String[] types = Strings.splitStringByCommaToArray(request.param("type")); String path = request.path(); boolean isTemplateRequest = isTemplateRequest(path); IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, multiSearchRequest.indicesOptions()); multiSearchRequest.add(RestActions.getRestContent(request), isTemplateRequest, indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex); client.execute(CoordinateMultiSearchAction.INSTANCE, multiSearchRequest, new RestToXContentListener<MultiSearchResponse>(channel)); }
Example 5
Source File: RestStatsFilterJoinCacheAction.java From siren-join with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { StatsFilterJoinCacheRequest statsFilterJoinCacheRequest = new StatsFilterJoinCacheRequest(); client.execute(StatsFilterJoinCacheAction.INSTANCE, statsFilterJoinCacheRequest, new RestToXContentListener<StatsFilterJoinCacheResponse>(channel)); }
Example 6
Source File: RestCoordinateSearchAction.java From siren-join with GNU Affero General Public License v3.0 | 4 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { SearchRequest searchRequest = new SearchRequest(); RestSearchAction.parseSearchRequest(searchRequest, request, parseFieldMatcher, null); client.execute(CoordinateSearchAction.INSTANCE, searchRequest, new RestStatusToXContentListener<SearchResponse>(channel)); }
Example 7
Source File: RestClearFilterJoinCacheAction.java From siren-join with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { ClearFilterJoinCacheRequest clearFilterJoinCacheRequest = new ClearFilterJoinCacheRequest(); client.execute(ClearFilterJoinCacheAction.INSTANCE, clearFilterJoinCacheRequest, new RestToXContentListener<ClearFilterJoinCacheResponse>(channel)); }