lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoss Man (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-4378) QueryParsers do not support negative boosts
Date Wed, 12 Sep 2012 01:58:07 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-4378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13453640#comment-13453640
] 

Hoss Man commented on LUCENE-4378:
----------------------------------

bq. In my opinion, a better approach is something like the BoostingQuery in lucene/queries
for this demoting of terms.

My confusion is that your argument seems like it confluates the concept/syntax with an implementation
-- you're saying you don't like a particular implementation, therefore you don't think QueryParser
should allow for the concept.

I'm suggesting we let the syntax in the grammer allow for the concept of negative boosts,
and then let the implementations of QueryParser decide what it means -- the default implementation
could be "error".  Some users could choose to have a subclass with "simple" implementation
(literally using the negative boost on the query) if it makes sense for them, and other users
could do other things.

For example: suppose i wanted to use BoostingQuery like you suggest, but i want to be able
to use it in some way with the QueryParser syntax.   If the grammer _allowed_ for "foo bar^-100"
to do *something* then by subclassing the QueryParser i could impelement demoting items using
this syntax with something like...

{noformat}
public MyParser extends QueryParser {
  @Override
  public BooleanQuery getBooleanQuery(List<BooleanClause> clauses,
                               boolean disableCoord) throws ParseException {
     BooleanQuery q = super.getBooleanQuery(clauses, disableCoord);
     Query result = q;
     for (clause : q.getClauses(){ 
       if (clause.getBoose() < 0) {
         q.removeClause(clause);
         penalty = -1/clause.getBoost();
         clause.setBoost(1);
         result = new BoostingQuery(result, clause, penalty)
     }
     return result;
  }
  @Override
  public void checkBoost(Query q, float boost) {
    // override super which will throw an exception if boost is negative
    // :NOOP:
  }
}
{noformat}



                
> QueryParsers do not support negative boosts
> -------------------------------------------
>
>                 Key: LUCENE-4378
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4378
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Hoss Man
>         Attachments: LUCENE-4378-test.patch
>
>
> Negative query boosts have been supported at the "Query" object level for a long time
(resulting in negative scores for matching documents), but evidently we never updated the
QueryParsers to know about this - attempting to specify a negative boost in the query string
results in a parse error.
> we should probably add this to the parser grammer(s)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message