Java Code Examples for org.elasticsearch.action.support.IndicesOptions#strictExpandOpenAndForbidClosed()
The following examples show how to use
org.elasticsearch.action.support.IndicesOptions#strictExpandOpenAndForbidClosed() .
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: MultiPercolateRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Embeds a percolate request to this multi percolate request */ public MultiPercolateRequest add(PercolateRequest request) { if (request.indices() == null && indices != null) { request.indices(indices); } if (request.documentType() == null && documentType != null) { request.documentType(documentType); } if (request.indicesOptions() == IndicesOptions.strictExpandOpenAndForbidClosed() && indicesOptions != IndicesOptions.strictExpandOpenAndForbidClosed()) { request.indicesOptions(indicesOptions); } requests.add(request); return this; }
Example 2
Source File: MultiSearchRequestBuilder.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Add a search request to execute. Note, the order is important, the search response will be returned in the * same order as the search requests. * <p> * If ignoreIndices has been set on the search request, then the indicesOptions of the multi search request * will not be used (if set). */ public MultiSearchRequestBuilder add(SearchRequest request) { if (request.indicesOptions() == IndicesOptions.strictExpandOpenAndForbidClosed() && request().indicesOptions() != IndicesOptions.strictExpandOpenAndForbidClosed()) { request.indicesOptions(request().indicesOptions()); } super.request.add(request); return this; }
Example 3
Source File: MultiSearchRequestBuilder.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Add a search request to execute. Note, the order is important, the search response will be returned in the * same order as the search requests. */ public MultiSearchRequestBuilder add(SearchRequestBuilder request) { if (request.request().indicesOptions() == IndicesOptions.strictExpandOpenAndForbidClosed() && request().indicesOptions() != IndicesOptions.strictExpandOpenAndForbidClosed()) { request.request().indicesOptions(request().indicesOptions()); } super.request.add(request); return this; }
Example 4
Source File: MultiSearchRequest.java From Elasticsearch with Apache License 2.0 | 4 votes |
public MultiSearchRequest add(BytesReference data, boolean isTemplateRequest, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, @Nullable String routing, IndicesOptions indicesOptions, boolean allowExplicitIndex) throws Exception { XContent xContent = XContentFactory.xContent(data); int from = 0; int length = data.length(); byte marker = xContent.streamSeparator(); while (true) { int nextMarker = findNextMarker(marker, from, data, length); if (nextMarker == -1) { break; } // support first line with \n if (nextMarker == 0) { from = nextMarker + 1; continue; } SearchRequest searchRequest = new SearchRequest(); if (indices != null) { searchRequest.indices(indices); } if (indicesOptions != null) { searchRequest.indicesOptions(indicesOptions); } if (types != null && types.length > 0) { searchRequest.types(types); } if (routing != null) { searchRequest.routing(routing); } searchRequest.searchType(searchType); IndicesOptions defaultOptions = IndicesOptions.strictExpandOpenAndForbidClosed(); // now parse the action if (nextMarker - from > 0) { try (XContentParser parser = xContent.createParser(data.slice(from, nextMarker - from))) { Map<String, Object> source = parser.map(); for (Map.Entry<String, Object> entry : source.entrySet()) { Object value = entry.getValue(); if ("index".equals(entry.getKey()) || "indices".equals(entry.getKey())) { if (!allowExplicitIndex) { throw new IllegalArgumentException("explicit index in multi percolate is not allowed"); } searchRequest.indices(nodeStringArrayValue(value)); } else if ("type".equals(entry.getKey()) || "types".equals(entry.getKey())) { searchRequest.types(nodeStringArrayValue(value)); } else if ("search_type".equals(entry.getKey()) || "searchType".equals(entry.getKey())) { searchRequest.searchType(nodeStringValue(value, null)); } else if ("request_cache".equals(entry.getKey()) || "requestCache".equals(entry.getKey())) { searchRequest.requestCache(nodeBooleanValue(value)); } else if ("preference".equals(entry.getKey())) { searchRequest.preference(nodeStringValue(value, null)); } else if ("routing".equals(entry.getKey())) { searchRequest.routing(nodeStringValue(value, null)); } } defaultOptions = IndicesOptions.fromMap(source, defaultOptions); } } searchRequest.indicesOptions(defaultOptions); // move pointers from = nextMarker + 1; // now for the body nextMarker = findNextMarker(marker, from, data, length); if (nextMarker == -1) { break; } if (isTemplateRequest) { searchRequest.templateSource(data.slice(from, nextMarker - from)); } else { searchRequest.source(data.slice(from, nextMarker - from)); } // move pointers from = nextMarker + 1; add(searchRequest); } return this; }
Example 5
Source File: DefaultElasticSearchService.java From vertx-elasticsearch-service with Apache License 2.0 | 4 votes |
@Override public void multiSearch(final List<MultiSearchQueryOptions> multiSearchQueryOptions, final MultiSearchOptions options, final Handler<AsyncResult<com.hubrick.vertx.elasticsearch.model.MultiSearchResponse>> resultHandler) { final MultiSearchRequestBuilder builder = client.prepareMultiSearch(); if (options != null) { if (options.getMaxConcurrentSearchRequests() != null) { builder.setMaxConcurrentSearchRequests(options.getMaxConcurrentSearchRequests()); } if (options.getIndicesOptions() != null) { final IndicesOptions defaultIndicesOptions = IndicesOptions.strictExpandOpenAndForbidClosed(); builder.setIndicesOptions( IndicesOptions.fromOptions( Optional.ofNullable(options.getIndicesOptions().getIgnoreUnavailable()).orElse(defaultIndicesOptions.ignoreUnavailable()), Optional.ofNullable(options.getIndicesOptions().getAllowNoIndices()).orElse(defaultIndicesOptions.allowNoIndices()), Optional.ofNullable(options.getIndicesOptions().getExpandToOpenIndices()).orElse(defaultIndicesOptions.expandWildcardsOpen()), Optional.ofNullable(options.getIndicesOptions().getExpandToClosedIndices()).orElse(defaultIndicesOptions.expandWildcardsClosed()), Optional.ofNullable(options.getIndicesOptions().getAllowAliasesToMultipleIndices()).orElse(defaultIndicesOptions.allowAliasesToMultipleIndices()), Optional.ofNullable(options.getIndicesOptions().getForbidClosedIndices()).orElse(defaultIndicesOptions.forbidClosedIndices()), Optional.ofNullable(options.getIndicesOptions().getIgnoreAliases()).orElse(defaultIndicesOptions.ignoreAliases()) ) ); } } for (MultiSearchQueryOptions multiSearchQueryOptionsItem : multiSearchQueryOptions) { final SearchRequestBuilder searchRequestBuilder = client.prepareSearch(multiSearchQueryOptionsItem.getIndices().toArray(new String[0])); populateSearchRequestBuilder(searchRequestBuilder, multiSearchQueryOptionsItem.getSearchOptions()); builder.add(searchRequestBuilder); } builder.execute(new ActionListener<MultiSearchResponse>() { @Override public void onResponse(final MultiSearchResponse multiSearchResponse) { resultHandler.handle(Future.succeededFuture(mapToMultiSearchResponse(multiSearchResponse))); } @Override public void onFailure(final Exception e) { handleFailure(resultHandler, e); } }); }