本文整理汇总了Java中org.apache.lucene.search.TermRangeQuery.setRewriteMethod方法的典型用法代码示例。如果您正苦于以下问题:Java TermRangeQuery.setRewriteMethod方法的具体用法?Java TermRangeQuery.setRewriteMethod怎么用?Java TermRangeQuery.setRewriteMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.TermRangeQuery
的用法示例。
在下文中一共展示了TermRangeQuery.setRewriteMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newRangeQuery
import org.apache.lucene.search.TermRangeQuery; //导入方法依赖的package包/类
/**
* Builds a new {@link TermRangeQuery} instance
*
* @param field
* Field
* @param part1
* min
* @param part2
* max
* @param startInclusive
* true if the start of the range is inclusive
* @param endInclusive
* true if the end of the range is inclusive
* @return new {@link TermRangeQuery} instance
*/
protected Query newRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
final BytesRef start;
final BytesRef end;
if (part1 == null) {
start = null;
} else {
start = analyzeRangeTerms ? getAnalyzer().normalize(field, part1) : new BytesRef(part1);
}
if (part2 == null) {
end = null;
} else {
end = analyzeRangeTerms ? getAnalyzer().normalize(field, part2) : new BytesRef(part2);
}
final TermRangeQuery query = new TermRangeQuery(field, start, end, startInclusive, endInclusive);
query.setRewriteMethod(multiTermRewriteMethod);
return query;
}
示例2: convertDate
import org.apache.lucene.search.TermRangeQuery; //导入方法依赖的package包/类
/**
* Converts a FreeTextDateQuery to a BooleanClause
*/
private BooleanClause convertDate(FreeTextDateQuery query)
{
TermRangeQuery termQuery = new TermRangeQuery(query.getField(), convertDate(query.getStart(), query),
convertDate(query.getEnd(), query), query.isIncludeStart(), query.isIncludeEnd());
termQuery.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
return new BooleanClause(termQuery, Occur.SHOULD);
}
示例3: build
import org.apache.lucene.search.TermRangeQuery; //导入方法依赖的package包/类
@Override
public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException {
TermRangeQueryNode rangeNode = (TermRangeQueryNode) queryNode;
FieldQueryNode upper = rangeNode.getUpperBound();
FieldQueryNode lower = rangeNode.getLowerBound();
String field = StringUtils.toString(rangeNode.getField());
String lowerText = lower.getTextAsString();
String upperText = upper.getTextAsString();
if (lowerText.length() == 0) {
lowerText = null;
}
if (upperText.length() == 0) {
upperText = null;
}
TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lowerText, upperText, rangeNode
.isLowerInclusive(), rangeNode.isUpperInclusive());
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode
.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) {
rangeQuery.setRewriteMethod(method);
}
return rangeQuery;
}
示例4: newRangeQuery
import org.apache.lucene.search.TermRangeQuery; //导入方法依赖的package包/类
@Override
protected Query newRangeQuery(String field, String part1, String part2,
boolean startInclusive, boolean endInclusive) {
if (isPass2ResolvingPhrases) {
// Must use old-style RangeQuery in order to produce a BooleanQuery
// that can be turned into SpanOr clause
TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, part1, part2, startInclusive, endInclusive);
rangeQuery.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
return rangeQuery;
}
return super.newRangeQuery(field, part1, part2, startInclusive, endInclusive);
}
示例5: newRangeQuery
import org.apache.lucene.search.TermRangeQuery; //导入方法依赖的package包/类
/**
* Builds a new TermRangeQuery instance
*
* @param field Field
* @param part1 min
* @param part2 max
* @param inclusive true if range is inclusive
* @return new TermRangeQuery instance
*/
protected Query newRangeQuery(String field, String part1, String part2, boolean inclusive) {
final TermRangeQuery query = new TermRangeQuery(field, part1, part2, inclusive, inclusive, rangeCollator);
query.setRewriteMethod(multiTermRewriteMethod);
return query;
}