本文整理汇总了Java中org.apache.lucene.search.PrefixFilter类的典型用法代码示例。如果您正苦于以下问题:Java PrefixFilter类的具体用法?Java PrefixFilter怎么用?Java PrefixFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrefixFilter类属于org.apache.lucene.search包,在下文中一共展示了PrefixFilter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPrefixFilter
import org.apache.lucene.search.PrefixFilter; //导入依赖的package包/类
public void testPrefixFilter() throws Exception {
Filter prefixFilter = new PrefixFilter(
new Term("category",
"/technology/computers"));
assertEquals("only /technology/computers/* books",
8,
TestUtil.hitCount(searcher,
allBooks,
prefixFilter));
}
示例2: newPrefixQuery
import org.apache.lucene.search.PrefixFilter; //导入依赖的package包/类
/**
* Creates new prefix query. Depending on {@link getUseConstantScoreQuery()}
* it's either {@link org.apache.lucene.search.ConstantScoreQuery} with
* {@link org.apache.lucene.search.PrefixFilter} or just
* {@link org.apache.lucene.search.PrefixQuery}.
* @param term term
* @return prefix query
*/
private Query newPrefixQuery(String fieldName, String term) {
return this.getUseConstantScoreQuery()?
new ConstantScoreQuery(new PrefixFilter(new Term(fieldName,term))):
new PrefixQuery(new Term(fieldName,term));
}