> 2) if I have to accept whole input string with all logic (AND, OR, ..) inside,
> I think it is easier to change TermQuery afterwards than parsing the
> string,
> since final result from query parser should be BooleanQuery (in your
> example),
> then we iterate through each BooleanClause, if the clause is still
> BooleanQuery,
> recursively go deep, if TermQuery, we may try to convert to
> WildCardQuery?
protected static void wildcardQuery(Query query) {
if (query instanceof BooleanQuery) {
BooleanQuery bQuery = (BooleanQuery)query;
for (BooleanClause clause: bQuery.getClauses()) {
if (clause.getQuery() instanceof TermQuery) {
Term term =
((TermQuery)clause.getQuery()).getTerm();
clause.setQuery(new WildcardQuery(new
Term(term.field(), "*" + term.text() + "*")));
}
else
wildcardQuery(clause.getQuery());
}
}
}
Does the trick (as long as the original query is a BooleanQuery). Thanks for
the suggestion!
-Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]