当前位置: 首页>>代码示例>>Java>>正文


Java Query.getClass方法代码示例

本文整理汇总了Java中org.apache.lucene.search.Query.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getClass方法的具体用法?Java Query.getClass怎么用?Java Query.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.search.Query的用法示例。


在下文中一共展示了Query.getClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: returnsDocsInOrder

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
private static boolean returnsDocsInOrder(Query query, SortAndFormats sf) {
    if (sf == null || Sort.RELEVANCE.equals(sf.sort)) {
        // sort by score
        // queries that return constant scores will return docs in index
        // order since Lucene tie-breaks on the doc id
        return query.getClass() == ConstantScoreQuery.class
                || query.getClass() == MatchAllDocsQuery.class;
    } else {
        return Sort.INDEXORDER.equals(sf.sort);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:QueryPhase.java

示例2: onUse

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public void onUse(Query query) {
    if (query.getClass() != TermQuery.class) {
        // Do not waste space in the history for term queries. The assumption
        // is that these queries are very fast so not worth caching
        in.onUse(query);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ElasticsearchQueryCachingPolicy.java

示例3: shouldCache

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public boolean shouldCache(Query query) throws IOException {
    if (query.getClass() == TermQuery.class) {
        return false;
    }
    return in.shouldCache(query);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ElasticsearchQueryCachingPolicy.java

示例4: analyze

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
/**
 * Extracts terms from the provided query. These terms are stored with the percolator query and
 * used by the percolate query's candidate query as fields to be query by. The candidate query
 * holds the terms from the document to be percolated and allows to the percolate query to ignore
 * percolator queries that we know would otherwise never match.
 *
 * <p>
 * When extracting the terms for the specified query, we can also determine if the percolator query is
 * always going to match. For example if a percolator query just contains a term query or a disjunction
 * query then when the candidate query matches with that, we know the entire percolator query always
 * matches. This allows the percolate query to skip the expensive memory index verification step that
 * it would otherwise have to execute (for example when a percolator query contains a phrase query or a
 * conjunction query).
 *
 * <p>
 * The query analyzer doesn't always extract all terms from the specified query. For example from a
 * boolean query with no should clauses or phrase queries only the longest term are selected,
 * since that those terms are likely to be the rarest. Boolean query's must_not clauses are always ignored.
 *
 * <p>
 * Sometimes the query analyzer can't always extract terms from a sub query, if that happens then
 * query analysis is stopped and an UnsupportedQueryException is thrown. So that the caller can mark
 * this query in such a way that the PercolatorQuery always verifies if this query with the MemoryIndex.
 */
public static Result analyze(Query query) {
    Class queryClass = query.getClass();
    if (queryClass.isAnonymousClass()) {
        // Sometimes queries have anonymous classes in that case we need the direct super class.
        // (for example blended term query)
        queryClass = queryClass.getSuperclass();
    }
    Function<Query, Result> queryProcessor = queryProcessors.get(queryClass);
    if (queryProcessor != null) {
        return queryProcessor.apply(query);
    } else {
        throw new UnsupportedQueryException(query);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:QueryAnalyzer.java


注:本文中的org.apache.lucene.search.Query.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。