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


Java VersionType类代码示例

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


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

示例1: handleRequest

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, Client client) {
    DeleteIndexedScriptRequest deleteIndexedScriptRequest = new DeleteIndexedScriptRequest(getScriptLang(request), request.param("id"));
    deleteIndexedScriptRequest.version(request.paramAsLong("version", deleteIndexedScriptRequest.version()));
    deleteIndexedScriptRequest.versionType(VersionType.fromString(request.param("version_type"), deleteIndexedScriptRequest.versionType()));
    client.deleteIndexedScript(deleteIndexedScriptRequest, new RestBuilderListener<DeleteIndexedScriptResponse>(channel) {
        @Override
        public RestResponse buildResponse(DeleteIndexedScriptResponse result, XContentBuilder builder) throws Exception {
            builder.startObject()
                    .field(Fields.FOUND, result.isFound())
                    .field(Fields._INDEX, result.getIndex())
                    .field(Fields._TYPE, result.getType())
                    .field(Fields._ID, result.getId())
                    .field(Fields._VERSION, result.getVersion())
                    .endObject();
            RestStatus status = OK;
            if (!result.isFound()) {
                status = NOT_FOUND;
            }
            return new BytesRestResponse(status, builder);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:RestDeleteIndexedScriptAction.java

示例2: indexDoc

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
protected Engine.Index indexDoc(IndexShard shard, String type, String id, String source, XContentType xContentType) throws IOException {
    final Engine.Index index;
    if (shard.routingEntry().primary()) {
        index = shard.prepareIndexOnPrimary(
            SourceToParse.source(SourceToParse.Origin.PRIMARY, shard.shardId().getIndexName(), type, id, new BytesArray(source),
                xContentType),
            Versions.MATCH_ANY,
            VersionType.INTERNAL,
            IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP,
            false);
    } else {
        index = shard.prepareIndexOnReplica(
            SourceToParse.source(SourceToParse.Origin.PRIMARY, shard.shardId().getIndexName(), type, id, new BytesArray(source),
                xContentType),
            randomInt(1 << 10), 1, VersionType.EXTERNAL, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false);
    }
    shard.index(index);
    return index;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:IndexShardTestCase.java

示例3: parseExistingDocPercolate

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) {
    String index = restRequest.param("index");
    String type = restRequest.param("type");
    percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("percolate_index", index)));
    percolateRequest.documentType(restRequest.param("percolate_type", type));

    GetRequest getRequest = new GetRequest(index, type,
            restRequest.param("id"));
    getRequest.routing(restRequest.param("routing"));
    getRequest.preference(restRequest.param("preference"));
    getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh()));
    getRequest.realtime(restRequest.paramAsBoolean("realtime", null));
    getRequest.version(RestActions.parseVersion(restRequest));
    getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType()));

    percolateRequest.getRequest(getRequest);
    percolateRequest.routing(restRequest.param("percolate_routing"));
    percolateRequest.preference(restRequest.param("percolate_preference"));
    percolateRequest.source(RestActions.getRestContent(restRequest));

    percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions()));
    executePercolate(percolateRequest, restChannel, client);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:RestPercolateAction.java

示例4: prepareRequest

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
    deleteRequest.routing(request.param("routing"));
    deleteRequest.parent(request.param("parent"));
    deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
    deleteRequest.setRefreshPolicy(request.param("refresh"));
    deleteRequest.version(RestActions.parseVersion(request));
    deleteRequest.versionType(VersionType.fromString(request.param("version_type"), deleteRequest.versionType()));

    String waitForActiveShards = request.param("wait_for_active_shards");
    if (waitForActiveShards != null) {
        deleteRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
    }

    return channel -> client.delete(deleteRequest, new RestStatusToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestDeleteAction.java

示例5: readURIParameters

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
public static void readURIParameters(TermVectorsRequest termVectorsRequest, RestRequest request) {
    String fields = request.param("fields");
    addFieldStringsFromParameter(termVectorsRequest, fields);
    termVectorsRequest.offsets(request.paramAsBoolean("offsets", termVectorsRequest.offsets()));
    termVectorsRequest.positions(request.paramAsBoolean("positions", termVectorsRequest.positions()));
    termVectorsRequest.payloads(request.paramAsBoolean("payloads", termVectorsRequest.payloads()));
    termVectorsRequest.routing(request.param("routing"));
    termVectorsRequest.realtime(request.paramAsBoolean("realtime", termVectorsRequest.realtime()));
    termVectorsRequest.version(RestActions.parseVersion(request, termVectorsRequest.version()));
    termVectorsRequest.versionType(VersionType.fromString(request.param("version_type"), termVectorsRequest.versionType()));
    termVectorsRequest.parent(request.param("parent"));
    termVectorsRequest.preference(request.param("preference"));
    termVectorsRequest.termStatistics(request.paramAsBoolean("termStatistics", termVectorsRequest.termStatistics()));
    termVectorsRequest.termStatistics(request.paramAsBoolean("term_statistics", termVectorsRequest.termStatistics()));
    termVectorsRequest.fieldStatistics(request.paramAsBoolean("fieldStatistics", termVectorsRequest.fieldStatistics()));
    termVectorsRequest.fieldStatistics(request.paramAsBoolean("field_statistics", termVectorsRequest.fieldStatistics()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestTermVectorsAction.java

示例6: validate

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = super.validateNonNullIndex();
    if (type == null) {
        validationException = ValidateActions.addValidationError("type is missing", validationException);
    }
    if (id == null) {
        validationException = ValidateActions.addValidationError("id is missing", validationException);
    }
    if (!versionType.validateVersionForReads(version)) {
        validationException = ValidateActions.addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]",
                validationException);
    }
    if (versionType == VersionType.FORCE) {
        validationException = ValidateActions.addValidationError("version type [force] may no longer be used", validationException);
    }
    return validationException;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:GetRequest.java

示例7: validate

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = super.validate();
    if (type == null) {
        validationException = addValidationError("type is missing", validationException);
    }
    if (id == null) {
        validationException = addValidationError("id is missing", validationException);
    }
    if (!versionType.validateVersionForWrites(version)) {
        validationException = addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException);
    }
    if (versionType == VersionType.FORCE) {
        validationException = addValidationError("version type [force] may no longer be used", validationException);
    }
    return validationException;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:DeleteRequest.java

示例8: readFrom

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    index = in.readString();
    type = in.readOptionalString();
    id = in.readString();
    routing = in.readOptionalString();
    int size = in.readVInt();
    if (size > 0) {
        fields = new String[size];
        for (int i = 0; i < size; i++) {
            fields[i] = in.readString();
        }
    }
    version = in.readLong();
    versionType = VersionType.fromValue(in.readByte());

    fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:MultiGetRequest.java

示例9: readFrom

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    type = in.readOptionalString();
    id = in.readOptionalString();
    routing = in.readOptionalString();
    parent = in.readOptionalString();
    if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) {
        in.readOptionalString(); // timestamp
        in.readOptionalWriteable(TimeValue::new); // ttl
    }
    source = in.readBytesReference();
    opType = OpType.fromId(in.readByte());
    version = in.readLong();
    versionType = VersionType.fromValue(in.readByte());
    pipeline = in.readOptionalString();
    isRetry = in.readBoolean();
    autoGeneratedTimestamp = in.readLong();
    if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
        contentType = in.readOptionalWriteable(XContentType::readFrom);
    } else {
        contentType = XContentFactory.xContentType(source);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:IndexRequest.java

示例10: scriptChangedOpType

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
protected RequestWrapper<?> scriptChangedOpType(RequestWrapper<?> request, OpType oldOpType, OpType newOpType) {
    switch (newOpType) {
    case NOOP:
        task.countNoop();
        return null;
    case DELETE:
        RequestWrapper<DeleteRequest> delete = wrap(new DeleteRequest(request.getIndex(), request.getType(), request.getId()));
        delete.setVersion(request.getVersion());
        delete.setVersionType(VersionType.INTERNAL);
        delete.setParent(request.getParent());
        delete.setRouting(request.getRouting());
        return delete;
    default:
        throw new IllegalArgumentException("Unsupported operation type change from [" + oldOpType + "] to [" + newOpType + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AbstractAsyncBulkByScrollAction.java

示例11: testExternalVersioningInitialDelete

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
public void testExternalVersioningInitialDelete() throws Exception {
    createIndex("test");
    ensureGreen();

    // Note - external version doesn't throw version conflicts on deletes of non existent records. This is different from internal versioning

    DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet();
    assertEquals(DocWriteResponse.Result.NOT_FOUND, deleteResponse.getResult());

    // this should conflict with the delete command transaction which told us that the object was deleted at version 17.
    assertThrows(
            client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.EXTERNAL).execute(),
            VersionConflictEngineException.class
    );

    IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(18).
            setVersionType(VersionType.EXTERNAL).execute().actionGet();
    assertThat(indexResponse.getVersion(), equalTo(18L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:SimpleVersioningIT.java

示例12: testVersioningIndexConflict

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
public void testVersioningIndexConflict() throws IOException {
    ParsedDocument doc = testParsedDocument("1", "test", null, testDocument(), B_1, null);
    Engine.Index index = indexForDoc(doc);
    Engine.IndexResult indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(1L));

    index = indexForDoc(doc);
    indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(2L));

    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 1L, VersionType.INTERNAL, Engine.Operation.Origin.PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(VersionConflictEngineException.class));

    // future versions should not work as well
    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 3L, VersionType.INTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(VersionConflictEngineException.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:InternalEngineTests.java

示例13: testForceVersioningNotAllowedExceptForOlderIndices

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
public void testForceVersioningNotAllowedExceptForOlderIndices() throws Exception {
    ParsedDocument doc = testParsedDocument("1", "test", null, testDocument(), B_1, null);
    Engine.Index index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 42, VersionType.FORCE, PRIMARY, 0, -1, false);

    Engine.IndexResult indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(IllegalArgumentException.class));
    assertThat(indexResult.getFailure().getMessage(), containsString("version type [FORCE] may not be used for indices created after 6.0"));

    IndexSettings oldIndexSettings = IndexSettingsModule.newIndexSettings("test", Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_5_0_0_beta1)
            .build());
    try (Store store = createStore();
            Engine engine = createEngine(oldIndexSettings, store, createTempDir(), NoMergePolicy.INSTANCE)) {
        index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 84, VersionType.FORCE, PRIMARY, 0, -1, false);
        Engine.IndexResult result = engine.index(index);
        assertTrue(result.hasFailure());
        assertThat(result.getFailure(), instanceOf(IllegalArgumentException.class));
        assertThat(result.getFailure().getMessage(), containsString("version type [FORCE] may not be used for non-translog operations"));

        index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 84, VersionType.FORCE,
                Engine.Operation.Origin.LOCAL_TRANSLOG_RECOVERY, 0, -1, false);
        result = engine.index(index);
        assertThat(result.getVersion(), equalTo(84L));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:InternalEngineTests.java

示例14: testVersioningIndexConflictWithFlush

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
public void testVersioningIndexConflictWithFlush() throws IOException {
    ParsedDocument doc = testParsedDocument("1", "test", null, testDocument(), B_1, null);
    Engine.Index index = indexForDoc(doc);
    Engine.IndexResult indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(1L));

    index = indexForDoc(doc);
    indexResult = engine.index(index);
    assertThat(indexResult.getVersion(), equalTo(2L));

    engine.flush();

    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 1L, VersionType.INTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(VersionConflictEngineException.class));

    // future versions should not work as well
    index = new Engine.Index(newUid(doc), doc, SequenceNumbersService.UNASSIGNED_SEQ_NO, 0, 3L, VersionType.INTERNAL, PRIMARY, 0, -1, false);
    indexResult = engine.index(index);
    assertTrue(indexResult.hasFailure());
    assertThat(indexResult.getFailure(), instanceOf(VersionConflictEngineException.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:InternalEngineTests.java

示例15: readFrom

import org.elasticsearch.index.VersionType; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    id = in.readString();
    int assignmentsSize = in.readVInt();
    if (assignmentsSize > 0) {
        updateAssignments = new Symbol[assignmentsSize];
        for (int i = 0; i < assignmentsSize; i++) {
            updateAssignments[i] = Symbol.fromStream(in);
        }
    }
    int missingAssignmentsSize = in.readVInt();
    if (missingAssignmentsSize > 0) {
        this.insertValues = new Object[missingAssignmentsSize];
        for (int i = 0; i < missingAssignmentsSize; i++) {
            insertValues[i] = insertValuesStreamer[i].readValueFrom(in);
        }
    }
    this.version = Version.readVersion(in).id;
    versionType = VersionType.fromValue(in.readByte());
    opType = IndexRequest.OpType.fromId(in.readByte());
    if (in.readBoolean()) {
        source = in.readBytesReference();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:ShardUpsertRequest.java


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