Search in sources :

Example 1 with IndexResponse

use of org.opensearch.action.index.IndexResponse in project fess by codelibs.

the class EsAbstractBehavior method delegateUpdate.

@Override
protected int delegateUpdate(final Entity entity, final UpdateOption<? extends ConditionBean> option) {
    final EsAbstractEntity esEntity = (EsAbstractEntity) entity;
    final IndexRequestBuilder builder = createUpdateRequest(esEntity);
    final IndexResponse response = builder.execute().actionGet(indexTimeout);
    final long seqNo = response.getSeqNo();
    if (seqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) {
        esEntity.asDocMeta().seqNo(seqNo);
    }
    final long primaryTerm = response.getPrimaryTerm();
    if (primaryTerm != SequenceNumbers.UNASSIGNED_PRIMARY_TERM) {
        esEntity.asDocMeta().primaryTerm(primaryTerm);
    }
    return 1;
}
Also used : IndexRequestBuilder(org.opensearch.action.index.IndexRequestBuilder) IndexResponse(org.opensearch.action.index.IndexResponse)

Example 2 with IndexResponse

use of org.opensearch.action.index.IndexResponse in project fess by codelibs.

the class EsAbstractBehavior method delegateUpdate.

@Override
protected int delegateUpdate(final Entity entity, final UpdateOption<? extends ConditionBean> option) {
    final EsAbstractEntity esEntity = (EsAbstractEntity) entity;
    final IndexRequestBuilder builder = createUpdateRequest(esEntity);
    final IndexResponse response = builder.execute().actionGet(indexTimeout);
    final long seqNo = response.getSeqNo();
    if (seqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) {
        esEntity.asDocMeta().seqNo(seqNo);
    }
    final long primaryTerm = response.getPrimaryTerm();
    if (primaryTerm != SequenceNumbers.UNASSIGNED_PRIMARY_TERM) {
        esEntity.asDocMeta().primaryTerm(primaryTerm);
    }
    return 1;
}
Also used : IndexRequestBuilder(org.opensearch.action.index.IndexRequestBuilder) IndexResponse(org.opensearch.action.index.IndexResponse)

Example 3 with IndexResponse

use of org.opensearch.action.index.IndexResponse in project fess by codelibs.

the class EsAbstractBehavior method delegateInsert.

// ===================================================================================
// Update
// ======
@Override
protected int delegateInsert(final Entity entity, final InsertOption<? extends ConditionBean> option) {
    final EsAbstractEntity esEntity = (EsAbstractEntity) entity;
    IndexRequestBuilder builder = createInsertRequest(esEntity);
    final IndexResponse response = builder.execute().actionGet(indexTimeout);
    esEntity.asDocMeta().id(response.getId());
    return response.getResult() == Result.CREATED ? 1 : 0;
}
Also used : IndexRequestBuilder(org.opensearch.action.index.IndexRequestBuilder) IndexResponse(org.opensearch.action.index.IndexResponse)

Example 4 with IndexResponse

use of org.opensearch.action.index.IndexResponse in project fess by codelibs.

the class EsAbstractBehavior method delegateUpdate.

@Override
protected int delegateUpdate(final Entity entity, final UpdateOption<? extends ConditionBean> option) {
    final EsAbstractEntity esEntity = (EsAbstractEntity) entity;
    final IndexRequestBuilder builder = createUpdateRequest(esEntity);
    final IndexResponse response = builder.execute().actionGet(indexTimeout);
    final long seqNo = response.getSeqNo();
    if (seqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) {
        esEntity.asDocMeta().seqNo(seqNo);
    }
    final long primaryTerm = response.getPrimaryTerm();
    if (primaryTerm != SequenceNumbers.UNASSIGNED_PRIMARY_TERM) {
        esEntity.asDocMeta().primaryTerm(primaryTerm);
    }
    return 1;
}
Also used : IndexRequestBuilder(org.opensearch.action.index.IndexRequestBuilder) IndexResponse(org.opensearch.action.index.IndexResponse)

Example 5 with IndexResponse

use of org.opensearch.action.index.IndexResponse in project fess by codelibs.

the class EsAbstractBehavior method delegateInsert.

// ===================================================================================
// Update
// ======
@Override
protected int delegateInsert(final Entity entity, final InsertOption<? extends ConditionBean> option) {
    final EsAbstractEntity esEntity = (EsAbstractEntity) entity;
    IndexRequestBuilder builder = createInsertRequest(esEntity);
    final IndexResponse response = builder.execute().actionGet(indexTimeout);
    esEntity.asDocMeta().id(response.getId());
    return response.getResult() == Result.CREATED ? 1 : 0;
}
Also used : IndexRequestBuilder(org.opensearch.action.index.IndexRequestBuilder) IndexResponse(org.opensearch.action.index.IndexResponse)

Aggregations

IndexRequestBuilder (org.opensearch.action.index.IndexRequestBuilder)6 IndexResponse (org.opensearch.action.index.IndexResponse)6