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

The following examples show how to use org.elasticsearch.index.mapper.internal.TypeFieldMapper. 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: PercolatorQueriesRegistry.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
private int loadQueries(IndexShard shard) {
    shard.refresh("percolator_load_queries");
    // NOTE: we acquire the searcher via the engine directly here since this is executed right
    // before the shard is marked as POST_RECOVERY
    try (Engine.Searcher searcher = shard.engine().acquireSearcher("percolator_load_queries")) {
        Query query = new TermQuery(new Term(TypeFieldMapper.NAME, PercolatorService.TYPE_NAME));
        QueriesLoaderCollector queryCollector = new QueriesLoaderCollector(PercolatorQueriesRegistry.this, logger, mapperService, indexFieldDataService);
        IndexSearcher indexSearcher = new IndexSearcher(searcher.reader());
        indexSearcher.setQueryCache(null);
        indexSearcher.search(query, queryCollector);
        Map<BytesRef, Query> queries = queryCollector.queries();
        for (Map.Entry<BytesRef, Query> entry : queries.entrySet()) {
            Query previousQuery = percolateQueries.put(entry.getKey(), entry.getValue());
            shardPercolateService.addedQuery(entry.getKey(), previousQuery, entry.getValue());
        }
        return queries.size();
    } catch (Exception e) {
        throw new PercolatorException(shardId.index(), "failed to load queries from percolator index", e);
    }
}
 
Example #2
Source File: ObjectMapper.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
ObjectMapper(String name, String fullPath, boolean enabled, Nested nested, Dynamic dynamic, ContentPath.Type pathType, Map<String, Mapper> mappers) {
    super(name);
    this.fullPath = fullPath;
    this.enabled = enabled;
    this.nested = nested;
    this.dynamic = dynamic;
    this.pathType = pathType;
    if (mappers == null) {
        this.mappers = new CopyOnWriteHashMap<>();
    } else {
        this.mappers = CopyOnWriteHashMap.copyOf(mappers);
    }
    this.nestedTypePathAsString = "__" + fullPath;
    this.nestedTypePathAsBytes = new BytesRef(nestedTypePathAsString);
    this.nestedTypeFilter = new TermQuery(new Term(TypeFieldMapper.NAME, nestedTypePathAsBytes));
}
 
Example #3
Source File: SingleFieldsVisitor.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public void postProcess(MappedFieldType fieldType) {
    if (uid != null) {
        switch (field) {
            case UidFieldMapper.NAME: addValue(field, uid.toString());
            case IdFieldMapper.NAME: addValue(field, uid.id());
            case TypeFieldMapper.NAME: addValue(field, uid.type());
        }
    }

    if (fieldsValues == null) {
        return;
    }
    List<Object> fieldValues = fieldsValues.get(fieldType.names().indexName());
    if (fieldValues == null) {
        return;
    }
    for (int i = 0; i < fieldValues.size(); i++) {
        fieldValues.set(i, fieldType.valueForSearch(fieldValues.get(i)));
    }
}
 
Example #4
Source File: SingleFieldsVisitor.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public Status needsField(FieldInfo fieldInfo) throws IOException {
    if (fieldInfo.name.equals(field)) {
        return Status.YES;
    }
    if (fieldInfo.name.equals(UidFieldMapper.NAME)) {
        if (TypeFieldMapper.NAME.equals(field) || IdFieldMapper.NAME.equals(field)) {
            return Status.YES;
        }
    }
    return Status.NO;
}
 
Example #5
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 #6
Source File: DocumentMapper.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public TypeFieldMapper typeMapper() {
    return metadataMapper(TypeFieldMapper.class);
}
 
Example #7
Source File: Queries.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static Query newNestedFilter() {
    return new PrefixQuery(new Term(TypeFieldMapper.NAME, new BytesRef("__")));
}