Java Code Examples for org.elasticsearch.index.engine.Engine#Create
The following examples show how to use
org.elasticsearch.index.engine.Engine#Create .
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: ShardIndexingService.java From Elasticsearch with Apache License 2.0 | 6 votes |
public void postCreate(Engine.Create create) { long took = create.endTime() - create.startTime(); totalStats.indexMetric.inc(took); totalStats.indexCurrent.dec(); StatsHolder typeStats = typeStats(create.type()); typeStats.indexMetric.inc(took); typeStats.indexCurrent.dec(); slowLog.postCreate(create, took); for (IndexingOperationListener listener : listeners) { try { listener.postCreate(create); } catch (Exception e) { logger.warn("postCreate listener [{}] failed", e, listener); } } }
Example 2
Source File: TransportReplicaShardIngestAction.java From elasticsearch-helper with Apache License 2.0 | 6 votes |
private void indexOperationOnReplica(IndexShard indexShard, IndexRequest indexRequest) { SourceToParse sourceToParse = SourceToParse.source(SourceToParse.Origin.REPLICA, indexRequest.source()) .type(indexRequest.type()) .id(indexRequest.id()) .routing(indexRequest.routing()) .parent(indexRequest.parent()) .timestamp(indexRequest.timestamp()) .ttl(indexRequest.ttl()); if (indexRequest.opType() == IndexRequest.OpType.INDEX) { Engine.Index index = indexShard.prepareIndexOnReplica(sourceToParse, indexRequest.version(), indexRequest.versionType(), false); indexShard.index(index); } else { Engine.Create create = indexShard.prepareCreateOnReplica(sourceToParse, indexRequest.version(), indexRequest.versionType(), false, indexRequest.autoGeneratedId()); indexShard.create(create); } }
Example 3
Source File: PercolatorQueriesRegistry.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Engine.Create preCreate(Engine.Create create) { // validate the query here, before we index if (PercolatorService.TYPE_NAME.equals(create.type())) { parsePercolatorDocument(create.id(), create.source()); } return create; }
Example 4
Source File: PercolatorQueriesRegistry.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void postCreateUnderLock(Engine.Create create) { // add the query under a doc lock if (PercolatorService.TYPE_NAME.equals(create.type())) { addPercolateQuery(create.id(), create.source()); } }
Example 5
Source File: ShardIndexingService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Engine.Create preCreate(Engine.Create create) { totalStats.indexCurrent.inc(); typeStats(create.type()).indexCurrent.inc(); for (IndexingOperationListener listener : listeners) { create = listener.preCreate(create); } return create; }
Example 6
Source File: ShardIndexingService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void postCreateUnderLock(Engine.Create create) { for (IndexingOperationListener listener : listeners) { try { listener.postCreateUnderLock(create); } catch (Exception e) { logger.warn("postCreateUnderLock listener [{}] failed", e, listener); } } }
Example 7
Source File: ShardIndexingService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void postCreate(Engine.Create create, Throwable ex) { for (IndexingOperationListener listener : listeners) { try { listener.postCreate(create, ex); } catch (Throwable t) { logger.warn("postCreate listener [{}] failed", t, listener); } } }
Example 8
Source File: IndexShard.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Engine.Create prepareCreateOnPrimary(SourceToParse source, long version, VersionType versionType, boolean canHaveDuplicates, boolean autoGeneratedId) { try { if (shardRouting.primary() == false) { throw new IllegalIndexShardStateException(shardId, state, "shard is not a primary"); } return prepareCreate(docMapper(source.type()), source, version, versionType, Engine.Operation.Origin.PRIMARY, state != IndexShardState.STARTED || canHaveDuplicates, autoGeneratedId); } catch (Throwable t) { verifyNotClosed(t); throw t; } }
Example 9
Source File: IndexShard.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Engine.Create prepareCreateOnReplica(SourceToParse source, long version, VersionType versionType, boolean canHaveDuplicates, boolean autoGeneratedId) { try { return prepareCreate(docMapper(source.type()), source, version, versionType, Engine.Operation.Origin.REPLICA, state != IndexShardState.STARTED || canHaveDuplicates, autoGeneratedId); } catch (Throwable t) { verifyNotClosed(t); throw t; } }
Example 10
Source File: IndexShard.java From Elasticsearch with Apache License 2.0 | 5 votes |
static Engine.Create prepareCreate(DocumentMapperForType docMapper, SourceToParse source, long version, VersionType versionType, Engine.Operation.Origin origin, boolean canHaveDuplicates, boolean autoGeneratedId) { long startTime = System.nanoTime(); ParsedDocument doc = docMapper.getDocumentMapper().parse(source); if (docMapper.getMapping() != null) { doc.addDynamicMappingsUpdate(docMapper.getMapping()); } return new Engine.Create(docMapper.getDocumentMapper().uidMapper().term(doc.uid().stringValue()), doc, version, versionType, origin, startTime, canHaveDuplicates, autoGeneratedId); }
Example 11
Source File: Translog.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Create(Engine.Create create) { this.id = create.id(); this.type = create.type(); this.source = create.source(); this.routing = create.routing(); this.parent = create.parent(); this.timestamp = create.timestamp(); this.ttl = create.ttl(); this.version = create.version(); this.versionType = create.versionType(); }
Example 12
Source File: IndexingSlowLog.java From Elasticsearch with Apache License 2.0 | 4 votes |
void postCreate(Engine.Create create, long tookInNanos) { postIndexing(create.parsedDoc(), tookInNanos); }
Example 13
Source File: IndexingOperationListener.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Called before the indexing occurs. */ public Engine.Create preCreate(Engine.Create create) { return create; }
Example 14
Source File: IndexingOperationListener.java From Elasticsearch with Apache License 2.0 | 2 votes |
/** * Called after create index operation occurred. */ public void postCreate(Engine.Create create) { }
Example 15
Source File: IndexingOperationListener.java From Elasticsearch with Apache License 2.0 | 2 votes |
/** * Called after create index operation occurred with exception. */ public void postCreate(Engine.Create create, Throwable ex) { }
Example 16
Source File: IndexingOperationListener.java From Elasticsearch with Apache License 2.0 | votes |
/** * Called after the indexing occurs, under a locking scheme to maintain * concurrent updates to the same doc. * <p> * Note, long operations should not occur under this callback. */ public void postCreateUnderLock(Engine.Create create) { }