Java Code Examples for org.elasticsearch.index.mapper.internal.TypeFieldMapper#NAME

The following examples show how to use org.elasticsearch.index.mapper.internal.TypeFieldMapper#NAME . 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: 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("__")));
}