/** * Sets the relative ttl value in milliseconds. It musts be greater than 0 as it makes little sense otherwise. */ public IndexRequestBuilder setTTL(long ttl) { request.ttl(ttl); return this; }
/** * Sets the ttl value as a time value expression. */ public IndexRequestBuilder setTTL(String ttl) { request.ttl(ttl); return this; }
/** * Sets the ttl as a {@link TimeValue} instance. */ public IndexRequestBuilder setTTL(TimeValue ttl) { request.ttl(ttl); return this; }
public IndexRequestBuilder<JsonInput, JsonOutput> ttl(long ttl) { request.ttl(ttl); return this; }
/** * Sets the ttl value as a time value expression. */ @Deprecated public IndexRequestBuilder setTTL(String ttl) { request.ttl(ttl); return this; }
/** * Sets the relative ttl value in milliseconds. It musts be greater than 0 as it makes little sense otherwise. */ @Deprecated public IndexRequestBuilder setTTL(long ttl) { request.ttl(ttl); return this; }
/** * Sets the ttl as a {@link TimeValue} instance. */ @Deprecated public IndexRequestBuilder setTTL(TimeValue ttl) { request.ttl(ttl); return this; }
/** * Set the new ttl of the document as a long. Note that if detectNoop is true (the default) * and the source of the document isn't changed then the ttl update won't take * effect. */ @Deprecated public UpdateRequestBuilder setTtl(Long ttl) { request.doc().ttl(ttl); return this; }
/** * Set the new ttl of the document as a time value expression. Note that if detectNoop is true (the default) * and the source of the document isn't changed then the ttl update won't take * effect. */ @Deprecated public UpdateRequestBuilder setTtl(String ttl) { request.doc().ttl(ttl); return this; }
/** * Set the new ttl of the document as a {@link TimeValue} instance. Note that if detectNoop is true (the default) * and the source of the document isn't changed then the ttl update won't take * effect. */ @Deprecated public UpdateRequestBuilder setTtl(TimeValue ttl) { request.doc().ttl(ttl); return this; } }
/** * Set the new ttl of the document as a long. Note that if detectNoop is true (the default) * and the source of the document isn't changed then the ttl update won't take * effect. */ public UpdateRequestBuilder setTtl(Long ttl) { request.doc().ttl(ttl); return this; }
/** * Set the new ttl of the document as a time value expression. Note that if detectNoop is true (the default) * and the source of the document isn't changed then the ttl update won't take * effect. */ public UpdateRequestBuilder setTtl(String ttl) { request.doc().ttl(ttl); return this; }
/** * Set the new ttl of the document as a {@link TimeValue} instance. Note that if detectNoop is true (the default) * and the source of the document isn't changed then the ttl update won't take * effect. */ public UpdateRequestBuilder setTtl(TimeValue ttl) { request.doc().ttl(ttl); return this; } }
/** * Copies the metadata from a hit to the index request. */ protected void copyMetadata(IndexRequest index, SearchHit doc) { index.parent(this.<String>fieldValue(doc, ParentFieldMapper.NAME)); copyRouting(index, doc); // Comes back as a Long but needs to be a string Long timestamp = fieldValue(doc, TimestampFieldMapper.NAME); if (timestamp != null) { index.timestamp(timestamp.toString()); } Long ttl = fieldValue(doc, TTLFieldMapper.NAME); if (ttl != null) { index.ttl(ttl); } }
/** * Copies the metadata from a hit to the index request. */ protected void copyMetadata(IndexRequest index, SearchHit doc) { index.parent(this.<String>fieldValue(doc, ParentFieldMapper.NAME)); copyRouting(index, doc); // Comes back as a Long but needs to be a string Long timestamp = fieldValue(doc, TimestampFieldMapper.NAME); if (timestamp != null) { index.timestamp(timestamp.toString()); } Long ttl = fieldValue(doc, TTLFieldMapper.NAME); if (ttl != null) { index.ttl(ttl); } }
/** Utility method to prepare an index operation on primary shards */ static Engine.Index prepareIndexOperationOnPrimary(IndexRequest request, IndexShard primary) { SourceToParse sourceToParse = SourceToParse.source(SourceToParse.Origin.PRIMARY, request.index(), request.type(), request.id(), request.source(), request.getContentType()).routing(request.routing()).parent(request.parent()) .timestamp(request.timestamp()).ttl(request.ttl()); return primary.prepareIndexOnPrimary(sourceToParse, request.version(), request.versionType(), request.getAutoGeneratedTimestamp(), request.isRetry()); }
/** * Execute the given {@link IndexRequest} on a replica shard, throwing a * {@link RetryOnReplicaException} if the operation needs to be re-tried. */ public static Engine.IndexResult executeIndexRequestOnReplica(IndexRequest request, IndexShard replica) throws IOException { final ShardId shardId = replica.shardId(); SourceToParse sourceToParse = SourceToParse.source(SourceToParse.Origin.REPLICA, shardId.getIndexName(), request.type(), request.id(), request.source(), request.getContentType()).routing(request.routing()).parent(request.parent()) .timestamp(request.timestamp()).ttl(request.ttl()); final Engine.Index operation; try { operation = replica.prepareIndexOnReplica(sourceToParse, request.version(), request.versionType(), request.getAutoGeneratedTimestamp(), request.isRetry()); } catch (MapperParsingException e) { return new Engine.IndexResult(e, request.version()); } Mapping update = operation.parsedDoc().dynamicMappingsUpdate(); if (update != null) { throw new RetryOnReplicaException(shardId, "Mappings are not available on the replica yet, triggered update: " + update); } return replica.index(operation); }
/** * Utility method to create either an index or a create operation depending * on the {@link IndexRequest.OpType} of the request. */ public static Engine.IndexingOperation prepareIndexOperationOnPrimary(BulkShardRequest shardRequest, IndexRequest request, IndexShard indexShard) { SourceToParse sourceToParse = SourceToParse.source(SourceToParse.Origin.PRIMARY, request.source()).index(request.index()).type(request.type()).id(request.id()) .routing(request.routing()).parent(request.parent()).timestamp(request.timestamp()).ttl(request.ttl()); boolean canHaveDuplicates = request.canHaveDuplicates(); if (shardRequest != null) { canHaveDuplicates |= shardRequest.canHaveDuplicates(); } if (request.opType() == IndexRequest.OpType.INDEX) { return indexShard.prepareIndexOnPrimary(sourceToParse, request.version(), request.versionType(), canHaveDuplicates); } else { assert request.opType() == IndexRequest.OpType.CREATE : request.opType(); return indexShard.prepareCreateOnPrimary(sourceToParse, request.version(), request.versionType(), canHaveDuplicates, request.autoGeneratedId()); } }