org.elasticsearch.index.mapper.internal.TimestampFieldMapper Java Examples

The following examples show how to use org.elasticsearch.index.mapper.internal.TimestampFieldMapper. 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: IndexShard.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
private void reindex(QueryFetchSearchResult hits, String index, String type) {
    logger.debug("Reindex: [index:{}, type:{}]", index, type);

    if (state == IndexShardState.STARTED) {
        for (InternalSearchHit hit : hits.fetchResult().hits().internalHits()) {
            // no difference between PRIMARY and REPLICA
            SourceToParse source = SourceToParse.source(SourceToParse.Origin.REPLICA, hit.sourceRef())
                    .index(index).type(type).id(hit.id());
            if (hit.field(ParentFieldMapper.NAME).getValue() != null) {
                source.parent((String) hit.field(ParentFieldMapper.NAME).getValue());
            }
            if (hit.field(TimestampFieldMapper.NAME).getValue() != null) {
                source.timestamp((long) hit.field(TimestampFieldMapper.NAME).getValue());
            }
            long version = 0;
            if (hit.field(VersionFieldMapper.NAME).getValue() != null) {
                version = (long) hit.field(VersionFieldMapper.NAME).getValue();
            }
            Engine.Index indexOp = prepareIndex(docMapper(source.type()), source, version, VersionType.EXTERNAL_GTE, Engine.Operation.Origin.RECOVERY, state != IndexShardState.STARTED);
            indexOp.setReindex(true);
            index(indexOp);
        }
    }
}
 
Example #2
Source File: UpdateHelper.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Prepares an update request by converting it into an index or delete request or an update response (no action).
 */
@SuppressWarnings("unchecked")
public Result prepare(UpdateRequest request, IndexShard indexShard) {
    final GetResult getResult = indexShard.getService().get(request.type(), request.id(),
            new String[]{RoutingFieldMapper.NAME, ParentFieldMapper.NAME, TTLFieldMapper.NAME, TimestampFieldMapper.NAME},
            true, request.version(), request.versionType(), FetchSourceContext.FETCH_SOURCE, false);
    return prepare(request, getResult);
}
 
Example #3
Source File: MapperTestUtils.java    From elasticsearch-analysis-baseform with Apache License 2.0 5 votes vote down vote up
private static Map<String, MetadataFieldMapper.TypeParser> registerBuiltInMetadataMappers() {
    Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers = new LinkedHashMap<>();
    metadataMapperParsers.put(UidFieldMapper.NAME, new UidFieldMapper.TypeParser());
    metadataMapperParsers.put(IdFieldMapper.NAME, new IdFieldMapper.TypeParser());
    metadataMapperParsers.put(RoutingFieldMapper.NAME, new RoutingFieldMapper.TypeParser());
    metadataMapperParsers.put(IndexFieldMapper.NAME, new IndexFieldMapper.TypeParser());
    metadataMapperParsers.put(SourceFieldMapper.NAME, new SourceFieldMapper.TypeParser());
    metadataMapperParsers.put(TypeFieldMapper.NAME, new TypeFieldMapper.TypeParser());
    metadataMapperParsers.put(AllFieldMapper.NAME, new AllFieldMapper.TypeParser());
    metadataMapperParsers.put(TimestampFieldMapper.NAME, new TimestampFieldMapper.TypeParser());
    metadataMapperParsers.put(TTLFieldMapper.NAME, new TTLFieldMapper.TypeParser());
    metadataMapperParsers.put(VersionFieldMapper.NAME, new VersionFieldMapper.TypeParser());
    metadataMapperParsers.put(ParentFieldMapper.NAME, new ParentFieldMapper.TypeParser());
    return metadataMapperParsers;
}
 
Example #4
Source File: DocumentMapper.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public TimestampFieldMapper timestampFieldMapper() {
    return metadataMapper(TimestampFieldMapper.class);
}