Is moneyTo
a numeric field? If so, you should use NumericRangeQuery instead of TermRangeQuery. If moneyTo
is a string field, it does not look like TermRangeQuery recognizes "*" as an open endpoint, and you should use null
instead.
Lucene custom QueryParser no results
-
14-10-2022 - |
سؤال
I've subclassed QueryParser in Apache Lucene to change input field name (user reuqest) to corresponding field name in my model class.
public class QueryParserMoney extends QueryParser {
public QueryParserMoney(Version matchVersion, String f, Analyzer a) {
super(matchVersion, f, a);
}
@Override
protected Query newTermQuery(Term term) {
if (term.field() == "money") {
PaddedIntegerBridge pB = new PaddedIntegerBridge();
TermRangeQuery trq = new TermRangeQuery("moneyTo",
pB.objectToString(Integer.parseInt(term.text())), "*",
true, true);
return trq;
}
return super.newTermQuery(term);
}
the input query is like money:5000
and i'm changing it to moneyTo:[5000 TO *]
generated query is ok, I'm checking query with Luke, but in Java I have 0 results.
Have you any suggestions where I'm making mistake?
المحلول
لا تنتمي إلى StackOverflow