19 Febr. Doug wrote:
>> How could I modify the queryParser to implement
>> default AND logic?
>I haven't tested this, but it should be as simple as changing line 318 of
>QueryParser.jj to:
> int ret = MOD_REQ;
>Unfortunately, I think this would end up disabling OR, so the proper change
>is more complex, requiring some changes to the addClause() method. This
>should also be something that folks can turn on and off.
>Doug
I attached a modified QueryParser.jj. Finally I modified addClause(). I also
attached a tester class.
Use:
QueryParser qp = new QueryParser(defaultField, analyzer);
qp.setMode(QueryParser.MODE_DEFAULT_END);
Please try & test it.
Some results:
Query: a b c d
classic mode: a b c d
new mode: +a +b +c +d
Query: a AND NOT b
classic mode: +a -b
new mode: +a -b
Query: a OR b
classic mode: a b
new mode: a b
Query: a b c -d
classic mode: a b c -d
new mode: +a +b +c -d
Query: Capital of Hungary
classic mode: capital of hungary
new mode: +capital +of +hungary
Peter
>> How could I modify the queryParser to implement
>> default AND logic?
>I haven't tested this, but it should be as simple as changing line 318 of
>QueryParser.jj to:
> int ret = MOD_REQ;
>Unfortunately, I think this would end up disabling OR, so the proper change
>is more complex, requiring some changes to the addClause() method. This
>should also be something that folks can turn on and off.
>Doug
I attached a modified QueryParser.jj. Finally I modified addClause(). I also
attached a tester class.
Use:
QueryParser qp = new QueryParser(defaultField, analyzer);
qp.setMode(QueryParser.MODE_DEFAULT_END);
Please try & test it.
Some results:
Query: a b c d
classic mode: a b c d
new mode: +a +b +c +d
Query: a AND NOT b
classic mode: +a -b
new mode: +a -b
Query: a OR b
classic mode: a b
new mode: a b
Query: a b c -d
classic mode: a b c -d
new mode: +a +b +c -d
Query: Capital of Hungary
classic mode: capital of hungary
new mode: +capital +of +hungary
Peter