org.elasticsearch.action.support.single.shard.SingleShardRequest Java Examples
The following examples show how to use
org.elasticsearch.action.support.single.shard.SingleShardRequest.
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: RequestUtils.java From ranger with Apache License 2.0 | 4 votes |
public static <Request extends ActionRequest> List<String> getIndexFromRequest(Request request) { List<String> indexs = new ArrayList<>(); if (request instanceof SingleShardRequest) { indexs.add(((SingleShardRequest<?>) request).index()); return indexs; } if (request instanceof ReplicationRequest) { indexs.add(((ReplicationRequest<?>) request).index()); return indexs; } if (request instanceof InstanceShardOperationRequest) { indexs.add(((InstanceShardOperationRequest<?>) request).index()); return indexs; } if (request instanceof CreateIndexRequest) { indexs.add(((CreateIndexRequest) request).index()); return indexs; } if (request instanceof PutMappingRequest) { indexs.add(((PutMappingRequest) request).getConcreteIndex().getName()); return indexs; } if (request instanceof SearchRequest) { return Arrays.asList(((SearchRequest) request).indices()); } if (request instanceof IndicesStatsRequest) { return Arrays.asList(((IndicesStatsRequest) request).indices()); } if (request instanceof OpenIndexRequest) { return Arrays.asList(((OpenIndexRequest) request).indices()); } if (request instanceof DeleteIndexRequest) { return Arrays.asList(((DeleteIndexRequest) request).indices()); } if (request instanceof BulkRequest) { @SuppressWarnings("rawtypes") List<DocWriteRequest<?>> requests = ((BulkRequest) request).requests(); if (CollectionUtils.isNotEmpty(requests)) { for (DocWriteRequest<?> docWriteRequest : requests) { indexs.add(docWriteRequest.index()); } return indexs; } } if (request instanceof MultiGetRequest) { List<Item> items = ((MultiGetRequest) request).getItems(); if (CollectionUtils.isNotEmpty(items)) { for (Item item : items) { indexs.add(item.index()); } return indexs; } } // No matched request type to find specific index , set default value * indexs.add("*"); return indexs; }