當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。