本文整理汇总了Java中org.apache.lucene.search.FieldCacheRangeFilter.newStringRange方法的典型用法代码示例。如果您正苦于以下问题:Java FieldCacheRangeFilter.newStringRange方法的具体用法?Java FieldCacheRangeFilter.newStringRange怎么用?Java FieldCacheRangeFilter.newStringRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.FieldCacheRangeFilter
的用法示例。
在下文中一共展示了FieldCacheRangeFilter.newStringRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRangeQuery
import org.apache.lucene.search.FieldCacheRangeFilter; //导入方法依赖的package包/类
/**
* Returns a Query instance for doing range searches on this field type. {@link org.apache.solr.search.SolrQueryParser}
* currently passes part1 and part2 as null if they are '*' respectively. minInclusive and maxInclusive are both true
* currently by SolrQueryParser but that may change in the future. Also, other QueryParser implementations may have
* different semantics.
* <p/>
* Sub-classes should override this method to provide their own range query implementation. They should strive to
* handle nulls in part1 and/or part2 as well as unequal minInclusive and maxInclusive parameters gracefully.
*
* @param parser the {@link org.apache.solr.search.QParser} calling the method
* @param field the schema field
* @param part1 the lower boundary of the range, nulls are allowed.
* @param part2 the upper boundary of the range, nulls are allowed
* @param minInclusive whether the minimum of the range is inclusive or not
* @param maxInclusive whether the maximum of the range is inclusive or not
* @return a Query instance to perform range search according to given parameters
*
*/
public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive) {
// TODO: change these all to use readableToIndexed/bytes instead (e.g. for unicode collation)
if (field.hasDocValues() && !field.indexed()) {
if (field.multiValued()) {
return new ConstantScoreQuery(DocTermOrdsRangeFilter.newBytesRefRange(
field.getName(),
part1 == null ? null : new BytesRef(toInternal(part1)),
part2 == null ? null : new BytesRef(toInternal(part2)),
minInclusive, maxInclusive));
} else {
return new ConstantScoreQuery(FieldCacheRangeFilter.newStringRange(
field.getName(),
part1 == null ? null : toInternal(part1),
part2 == null ? null : toInternal(part2),
minInclusive, maxInclusive));
}
} else {
MultiTermQuery rangeQuery = TermRangeQuery.newStringRange(
field.getName(),
part1 == null ? null : toInternal(part1),
part2 == null ? null : toInternal(part2),
minInclusive, maxInclusive);
rangeQuery.setRewriteMethod(getRewriteMethod(parser, field));
return rangeQuery;
}
}
示例2: getRangeQuery
import org.apache.lucene.search.FieldCacheRangeFilter; //导入方法依赖的package包/类
/**
* Returns a Query instance for doing range searches on this field type. {@link org.apache.solr.search.SolrQueryParser}
* currently passes part1 and part2 as null if they are '*' respectively. minInclusive and maxInclusive are both true
* currently by SolrQueryParser but that may change in the future. Also, other QueryParser implementations may have
* different semantics.
* <p/>
* Sub-classes should override this method to provide their own range query implementation. They should strive to
* handle nulls in part1 and/or part2 as well as unequal minInclusive and maxInclusive parameters gracefully.
*
* @param field the schema field
* @param part1 the lower boundary of the range, nulls are allowed.
* @param part2 the upper boundary of the range, nulls are allowed
* @param minInclusive whether the minimum of the range is inclusive or not
* @param maxInclusive whether the maximum of the range is inclusive or not
* @return a Query instance to perform range search according to given parameters
*
*/
public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive) {
// TODO: change these all to use readableToIndexed/bytes instead (e.g. for unicode collation)
if (field.hasDocValues() && !field.indexed()) {
if (field.multiValued()) {
return new ConstantScoreQuery(DocTermOrdsRangeFilter.newBytesRefRange(
field.getName(),
part1 == null ? null : new BytesRef(toInternal(part1)),
part2 == null ? null : new BytesRef(toInternal(part2)),
minInclusive, maxInclusive));
} else {
return new ConstantScoreQuery(FieldCacheRangeFilter.newStringRange(
field.getName(),
part1 == null ? null : toInternal(part1),
part2 == null ? null : toInternal(part2),
minInclusive, maxInclusive));
}
} else {
MultiTermQuery rangeQuery = TermRangeQuery.newStringRange(
field.getName(),
part1 == null ? null : toInternal(part1),
part2 == null ? null : toInternal(part2),
minInclusive, maxInclusive);
rangeQuery.setRewriteMethod(getRewriteMethod(parser, field));
return rangeQuery;
}
}
示例3: testFieldCacheRangeFilter
import org.apache.lucene.search.FieldCacheRangeFilter; //导入方法依赖的package包/类
public void testFieldCacheRangeFilter() throws Exception {
Filter filter = FieldCacheRangeFilter.newStringRange("title2", "d", "j", true, true);
assertEquals(3, TestUtil.hitCount(searcher, allBooks, filter));
filter = FieldCacheRangeFilter.newIntRange("pubmonth",
201001,
201006,
true,
true);
assertEquals(2, TestUtil.hitCount(searcher, allBooks, filter));
}