当前位置: 首页>>代码示例>>Java>>正文


Java IndicesOptions类代码示例

本文整理汇总了Java中org.elasticsearch.action.support.IndicesOptions的典型用法代码示例。如果您正苦于以下问题:Java IndicesOptions类的具体用法?Java IndicesOptions怎么用?Java IndicesOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IndicesOptions类属于org.elasticsearch.action.support包,在下文中一共展示了IndicesOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postIndexAsyncActions

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
/**
 * Maybe refresh, force merge, or flush then always make sure there aren't too many in flight async operations.
 */
private void postIndexAsyncActions(String[] indices, List<CountDownLatch> inFlightAsyncOperations, boolean maybeFlush) throws InterruptedException {
    if (rarely()) {
        if (rarely()) {
            client().admin().indices().prepareRefresh(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute(
                new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
        } else if (maybeFlush && rarely()) {
            if (randomBoolean()) {
                client().admin().indices().prepareFlush(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute(
                    new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
            } else {
                client().admin().indices().syncedFlush(syncedFlushRequest(indices).indicesOptions(IndicesOptions.lenientExpandOpen()),
                    new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
            }
        } else if (rarely()) {
            client().admin().indices().prepareForceMerge(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).setMaxNumSegments(between(1, 10)).setFlush(maybeFlush && randomBoolean()).execute(
                new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
        }
    }
    while (inFlightAsyncOperations.size() > MAX_IN_FLIGHT_ASYNC_INDEXES) {
        int waitFor = between(0, inFlightAsyncOperations.size() - 1);
        inFlightAsyncOperations.remove(waitFor).await();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ESIntegTestCase.java

示例2: handleRequest

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    ForceMergeRequest mergeRequest = new ForceMergeRequest(Strings.splitStringByCommaToArray(request.param("index")));
    mergeRequest.indicesOptions(IndicesOptions.fromRequest(request, mergeRequest.indicesOptions()));
    mergeRequest.maxNumSegments(request.paramAsInt("max_num_segments", mergeRequest.maxNumSegments()));
    mergeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", mergeRequest.onlyExpungeDeletes()));
    mergeRequest.flush(request.paramAsBoolean("flush", mergeRequest.flush()));
    client.admin().indices().forceMerge(mergeRequest, new RestBuilderListener<ForceMergeResponse>(channel) {
        @Override
        public RestResponse buildResponse(ForceMergeResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:RestForceMergeAction.java

示例3: testMultipleWildcards

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
public void testMultipleWildcards() {
    MetaData.Builder mdBuilder = MetaData.builder()
            .put(indexBuilder("testXXX"))
            .put(indexBuilder("testXXY"))
            .put(indexBuilder("testXYY"))
            .put(indexBuilder("testYYY"))
            .put(indexBuilder("kuku"))
            .put(indexBuilder("kukuYYY"));

    ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
    IndexNameExpressionResolver.WildcardExpressionResolver resolver = new IndexNameExpressionResolver.WildcardExpressionResolver();

    IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.lenientExpandOpen());
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("test*X*"))), equalTo(newHashSet("testXXX", "testXXY", "testXYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("test*X*Y"))), equalTo(newHashSet("testXXY", "testXYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("kuku*Y*"))), equalTo(newHashSet("kukuYYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("*Y*"))), equalTo(newHashSet("testXXY", "testXYY", "testYYY", "kukuYYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("test*Y*X"))).size(), equalTo(0));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("*Y*X"))).size(), equalTo(0));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:WildcardExpressionResolverTests.java

示例4: readFrom

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);

    indices = new String[in.readVInt()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = in.readString();
    }

    routing = in.readOptionalString();
    preference = in.readOptionalString();

    if (in.getVersion().onOrBefore(Version.V_5_1_1_UNRELEASED)) {
        //types
        in.readStringArray();
    }
    indicesOptions = IndicesOptions.readIndicesOptions(in);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ClusterSearchShardsRequest.java

示例5: resolve

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
@Override
public List<String> resolve(Context context, List<String> expressions) {
    IndicesOptions options = context.getOptions();
    MetaData metaData = context.getState().metaData();
    if (options.expandWildcardsClosed() == false && options.expandWildcardsOpen() == false) {
        return expressions;
    }

    if (isEmptyOrTrivialWildcard(expressions)) {
        return resolveEmptyOrTrivialWildcard(options, metaData, true);
    }

    Set<String> result = innerResolve(context, expressions, options, metaData);

    if (result == null) {
        return expressions;
    }
    if (result.isEmpty() && !options.allowNoIndices()) {
        IndexNotFoundException infe = new IndexNotFoundException((String)null);
        infe.setResources("index_or_alias", expressions.toArray(new String[0]));
        throw infe;
    }
    return new ArrayList<>(result);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:IndexNameExpressionResolver.java

示例6: RestoreRequest

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
/**
 * Constructs new restore request
 *
 * @param repositoryName     repositoryName
 * @param snapshotName       snapshotName
 * @param indices            list of indices to restore
 * @param indicesOptions     indices options
 * @param renamePattern      pattern to rename indices
 * @param renameReplacement  replacement for renamed indices
 * @param settings           repository specific restore settings
 * @param masterNodeTimeout  master node timeout
 * @param includeGlobalState include global state into restore
 * @param partial            allow partial restore
 * @param indexSettings      index settings that should be changed on restore
 * @param ignoreIndexSettings index settings that shouldn't be restored
 * @param cause              cause for restoring the snapshot
 */
public RestoreRequest(String repositoryName, String snapshotName, String[] indices, IndicesOptions indicesOptions,
                      String renamePattern, String renameReplacement, Settings settings,
                      TimeValue masterNodeTimeout, boolean includeGlobalState, boolean partial, boolean includeAliases,
                      Settings indexSettings, String[] ignoreIndexSettings, String cause) {
    this.repositoryName = Objects.requireNonNull(repositoryName);
    this.snapshotName = Objects.requireNonNull(snapshotName);
    this.indices = indices;
    this.renamePattern = renamePattern;
    this.renameReplacement = renameReplacement;
    this.indicesOptions = indicesOptions;
    this.settings = settings;
    this.masterNodeTimeout = masterNodeTimeout;
    this.includeGlobalState = includeGlobalState;
    this.partial = partial;
    this.includeAliases = includeAliases;
    this.indexSettings = indexSettings;
    this.ignoreIndexSettings = ignoreIndexSettings;
    this.cause = cause;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:RestoreService.java

示例7: dispatch

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
public ListenableFuture<Long> dispatch(final RestoreSnapshotAnalyzedStatement analysis) {
    final SettableFuture<Long> resultFuture = SettableFuture.create();

    boolean waitForCompletion = analysis.settings().getAsBoolean(WAIT_FOR_COMPLETION.settingName(), WAIT_FOR_COMPLETION.defaultValue());
    boolean ignoreUnavailable = analysis.settings().getAsBoolean(IGNORE_UNAVAILABLE.settingName(), IGNORE_UNAVAILABLE.defaultValue());

    // ignore_unavailable as set by statement
    IndicesOptions indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, true, true, false, IndicesOptions.lenientExpandOpen());

    RestoreSnapshotRequest request = new RestoreSnapshotRequest(analysis.repositoryName(), analysis.snapshotName())
            .indices(analysis.indices())
            .indicesOptions(indicesOptions)
            .settings(analysis.settings())
            .waitForCompletion(waitForCompletion)
            .includeGlobalState(false)
            .includeAliases(true);
    ActionListener<RestoreSnapshotResponse> listener = ActionListeners.wrap(resultFuture, Functions.constant(1L));
    transportActionProvider.transportRestoreSnapshotAction().execute(request, listener);
    return resultFuture;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:SnapshotRestoreDDLDispatcher.java

示例8: testAllMissingLenient

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
public void testAllMissingLenient() throws Exception {
    createIndex("test1");
    client().prepareIndex("test1", "type", "1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
    SearchResponse response = client().prepareSearch("test2")
            .setIndicesOptions(IndicesOptions.lenientExpandOpen())
            .setQuery(matchAllQuery())
            .execute().actionGet();
    assertHitCount(response, 0L);

    response = client().prepareSearch("test2","test3").setQuery(matchAllQuery())
            .setIndicesOptions(IndicesOptions.lenientExpandOpen())
            .execute().actionGet();
    assertHitCount(response, 0L);

    //you should still be able to run empty searches without things blowing up
    response  = client().prepareSearch()
            .setIndicesOptions(IndicesOptions.lenientExpandOpen())
            .setQuery(matchAllQuery())
            .execute().actionGet();
    assertHitCount(response, 1L);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:IndicesOptionsIntegrationIT.java

示例9: deleteOrphanedPartitions

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
/**
 * if some orphaned partition with the same table name still exist,
 * delete them beforehand as they would create unwanted and maybe invalid
 * initial data.
 *
 * should never delete partitions of existing partitioned tables
 */
private void deleteOrphanedPartitions(final CreateTableResponseListener listener, TableIdent tableIdent) {
    String partitionWildCard = PartitionName.templateName(tableIdent.schema(), tableIdent.name()) + "*";
    String[] orphans = indexNameExpressionResolver.concreteIndices(clusterService.state(), IndicesOptions.strictExpand(), partitionWildCard);
    if (orphans.length > 0) {
        if (logger.isDebugEnabled()) {
            logger.debug("Deleting orphaned partitions: {}", Joiner.on(", ").join(orphans));
        }
        transportActionProvider.transportDeleteIndexAction().execute(new DeleteIndexRequest(orphans), new ActionListener<DeleteIndexResponse>() {
            @Override
            public void onResponse(DeleteIndexResponse response) {
                if (!response.isAcknowledged()) {
                    warnNotAcknowledged("deleting orphans");
                }
                listener.onResponse(SUCCESS_RESULT);
            }

            @Override
            public void onFailure(Throwable e) {
                listener.onFailure(e);
            }
        });
    } else {
        listener.onResponse(SUCCESS_RESULT);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:TableCreator.java

示例10: testIndexNameFiltering

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
public void testIndexNameFiltering() {
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{}, new String[]{"foo", "bar", "baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"*"}, new String[]{"foo", "bar", "baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"_all"}, new String[]{"foo", "bar", "baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo", "bar", "baz"}, new String[]{"foo", "bar", "baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo"}, new String[]{"foo"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"baz", "not_available"}, new String[]{"baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"ba*", "-bar", "-baz"}, new String[]{});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"-bar"}, new String[]{"foo", "baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"-ba*"}, new String[]{"foo"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"+ba*"}, new String[]{"bar", "baz"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"+bar", "+foo"}, new String[]{"bar", "foo"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"zzz", "bar"}, IndicesOptions.lenientExpandOpen(), new String[]{"bar"});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{""}, IndicesOptions.lenientExpandOpen(), new String[]{});
    assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo", "", "ba*"}, IndicesOptions.lenientExpandOpen(), new String[]{"foo", "bar", "baz"});
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:SnapshotUtilsTests.java

示例11: mutate

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
private SearchRequest mutate(SearchRequest searchRequest) throws IOException {
    SearchRequest mutation = copyRequest(searchRequest);
    List<Runnable> mutators = new ArrayList<>();
    mutators.add(() -> mutation.indices(ArrayUtils.concat(searchRequest.indices(), new String[] { randomAsciiOfLength(10) })));
    mutators.add(() -> mutation.indicesOptions(randomValueOtherThan(searchRequest.indicesOptions(),
            () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()))));
    mutators.add(() -> mutation.types(ArrayUtils.concat(searchRequest.types(), new String[] { randomAsciiOfLength(10) })));
    mutators.add(() -> mutation.preference(randomValueOtherThan(searchRequest.preference(), () -> randomAsciiOfLengthBetween(3, 10))));
    mutators.add(() -> mutation.routing(randomValueOtherThan(searchRequest.routing(), () -> randomAsciiOfLengthBetween(3, 10))));
    mutators.add(() -> mutation.requestCache((randomValueOtherThan(searchRequest.requestCache(), () -> randomBoolean()))));
    mutators.add(() -> mutation
            .scroll(randomValueOtherThan(searchRequest.scroll(), () -> new Scroll(new TimeValue(randomNonNegativeLong() % 100000)))));
    mutators.add(() -> mutation.searchType(randomValueOtherThan(searchRequest.searchType(), () -> randomFrom(SearchType.values()))));
    mutators.add(() -> mutation.source(randomValueOtherThan(searchRequest.source(), this::createSearchSourceBuilder)));
    randomFrom(mutators).run();
    return mutation;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:SearchRequestTests.java

示例12: readFrom

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    snapshot = in.readString();
    repository = in.readString();
    indices = in.readStringArray();
    indicesOptions = IndicesOptions.readIndicesOptions(in);
    renamePattern = in.readOptionalString();
    renameReplacement = in.readOptionalString();
    waitForCompletion = in.readBoolean();
    includeGlobalState = in.readBoolean();
    partial = in.readBoolean();
    includeAliases = in.readBoolean();
    settings = readSettingsFromStream(in);
    indexSettings = readSettingsFromStream(in);
    ignoreIndexSettings = in.readStringArray();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:RestoreSnapshotRequest.java

示例13: add

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
public MultiSearchTemplateRequestBuilder add(SearchTemplateRequestBuilder request) {
    if (request.request().getRequest().indicesOptions() == IndicesOptions.strictExpandOpenAndForbidClosed()
            && request().indicesOptions() != IndicesOptions.strictExpandOpenAndForbidClosed()) {
        request.request().getRequest().indicesOptions(request().indicesOptions());
    }

    super.request.add(request);
    return this;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:MultiSearchTemplateRequestBuilder.java

示例14: testUpdateByQueryRequestImplementsIndicesRequestReplaceable

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
public void testUpdateByQueryRequestImplementsIndicesRequestReplaceable() {
    int numIndices = between(1, 100);
    String[] indices = new String[numIndices];
    for (int i = 0; i < numIndices; i++) {
        indices[i] = randomSimpleString(random(), 1, 30);
    }

    SearchRequest searchRequest = new SearchRequest(indices);
    IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
    searchRequest.indicesOptions(indicesOptions);

    UpdateByQueryRequest request = new UpdateByQueryRequest(searchRequest);
    for (int i = 0; i < numIndices; i++) {
        assertEquals(indices[i], request.indices()[i]);
    }

    assertSame(indicesOptions, request.indicesOptions());
    assertSame(request.indicesOptions(), request.getSearchRequest().indicesOptions());

    int numNewIndices = between(1, 100);
    String[] newIndices = new String[numNewIndices];
    for (int i = 0; i < numNewIndices; i++) {
        newIndices[i] = randomSimpleString(random(), 1, 30);
    }
    request.indices(newIndices);
    for (int i = 0; i < numNewIndices; i++) {;
        assertEquals(newIndices[i], request.indices()[i]);
    }
    for (int i = 0; i < numNewIndices; i++) {;
        assertEquals(newIndices[i], request.getSearchRequest().indices()[i]);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:UpdateByQueryRequestTests.java

示例15: readFrom

import org.elasticsearch.action.support.IndicesOptions; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    indices = in.readStringArray();
    types = in.readStringArray();
    indicesOptions = IndicesOptions.readIndicesOptions(in);
    local = in.readBoolean();
    fields = in.readStringArray();
    includeDefaults = in.readBoolean();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:GetFieldMappingsRequest.java


注:本文中的org.elasticsearch.action.support.IndicesOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。