There is a lot on this topic if you search the archives.
Things to check out:
Precedence QueryParser (I think its in Lucene contrib packages - I don't
believe its perfect but I have not tried it)
Qsol: myhardshadow.com/qsol (A query parser I wrote that has fully
customizable precedence support - don't be fooled by the stale
website...I am actually working on version 2 as i have time)
- Mark
Martin Dietze wrote:
Hi,
I've been going nuts trying to use LuceneParser parse query
strings using the default operator AND correctly:
String queryString = getQueryString();
QueryParser parser = new QueryParser("text", new StandardAnalyzer());
parser.setDefaultOperator(QueryParser.AND_OPERATOR);
try {
Query q = parser.parse(queryString);
LOG.info("q: " + q.toString());
/* [...] */
Here's two example queries and the results I get with and
without the `setDefaultOperator()' statetment:
Query: hose AND cat:Wohnen cat:Mode OR color:blau
- Default-Op OR: (+text:hose +cat:Wohnen) cat:Mode color:blau
- Default-Op AND: +(+text:hose +cat:Wohnen) cat:Mode color:blau
Query: hose AND ( cat:Wohnen cat:Mode ) OR color:blau
- Default-Op OR: (+text:hose +(cat:Wohnen cat:Mode)) color:blau
- Default-Op AND: (+text:hose +(+cat:Wohnen +cat:Mode)) color:blau
It seems like theparser handles the default case well, but what
I get with the default operator set to AND is completely
incorrect. I've seen this behaviour with both version 2.1.0 and
2.2.0.
Any hints?
Cheers,
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]