Search in sources :

Example 6 with Mapping

use of org.elasticsearch.index.mapper.Mapping in project crate by crate.

the class IndexShard method applyIndexOperation.

private Engine.IndexResult applyIndexOperation(Engine engine, long seqNo, long opPrimaryTerm, long version, @Nullable VersionType versionType, long ifSeqNo, long ifPrimaryTerm, long autoGeneratedTimeStamp, boolean isRetry, Engine.Operation.Origin origin, SourceToParse sourceToParse) throws IOException {
    assert opPrimaryTerm <= getOperationPrimaryTerm() : "op term [ " + opPrimaryTerm + " ] > shard term [" + getOperationPrimaryTerm() + "]";
    ensureWriteAllowed(origin);
    Engine.Index operation;
    try {
        operation = prepareIndex(mapperService.documentMapper(), sourceToParse, seqNo, opPrimaryTerm, version, versionType, origin, autoGeneratedTimeStamp, isRetry, ifSeqNo, ifPrimaryTerm);
        Mapping update = operation.parsedDoc().dynamicMappingsUpdate();
        if (update != null) {
            return new Engine.IndexResult(update);
        }
    } catch (Exception e) {
        // We treat any exception during parsing and or mapping update as a document level failure
        // with the exception side effects of closing the shard. Since we don't have the shard, we
        // can not raise an exception that may block any replication of previous operations to the
        // replicas
        verifyNotClosed(e);
        return new Engine.IndexResult(e, version, opPrimaryTerm, seqNo);
    }
    return index(engine, operation);
}
Also used : Mapping(org.elasticsearch.index.mapper.Mapping) ReadOnlyEngine(org.elasticsearch.index.engine.ReadOnlyEngine) Engine(org.elasticsearch.index.engine.Engine) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) WriteStateException(org.elasticsearch.gateway.WriteStateException) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) ClosedByInterruptException(java.nio.channels.ClosedByInterruptException) ThreadInterruptedException(org.apache.lucene.util.ThreadInterruptedException) RecoveryFailedException(org.elasticsearch.indices.recovery.RecoveryFailedException) EngineException(org.elasticsearch.index.engine.EngineException) IOException(java.io.IOException) ElasticsearchException(org.elasticsearch.ElasticsearchException) TimeoutException(java.util.concurrent.TimeoutException) RefreshFailedEngineException(org.elasticsearch.index.engine.RefreshFailedEngineException)

Aggregations

Mapping (org.elasticsearch.index.mapper.Mapping)6 IOException (java.io.IOException)2 BytesReference (org.elasticsearch.common.bytes.BytesReference)2 CompressedXContent (org.elasticsearch.common.compress.CompressedXContent)2 Engine (org.elasticsearch.index.engine.Engine)2 DocumentMapper (org.elasticsearch.index.mapper.DocumentMapper)2 ParsedDocument (org.elasticsearch.index.mapper.ParsedDocument)2 SourceToParse (org.elasticsearch.index.mapper.SourceToParse)2 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1 ClosedByInterruptException (java.nio.channels.ClosedByInterruptException)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)1 ThreadInterruptedException (org.apache.lucene.util.ThreadInterruptedException)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 BytesArray (org.elasticsearch.common.bytes.BytesArray)1 WriteStateException (org.elasticsearch.gateway.WriteStateException)1 IndexNotFoundException (org.elasticsearch.index.IndexNotFoundException)1