本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}