You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2011/06/16 13:13:47 UTC

[jira] [Updated] (LUCENE-3208) Move Query.weight() to IndexSearcher as protected method

     [ https://issues.apache.org/jira/browse/LUCENE-3208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler updated LUCENE-3208:
----------------------------------

    Attachment: LUCENE-3208.patch

First patch with some minor hacks and 2 disabled tests.

The problems:
- 2 tests are in Span Package and call the IndexSearcher.createWeight method, which is protected. I commented them out for now
- QueryValueSource is still to be investigated, I dont completely understand how it works, it looks fine for now (tests pass) but I have to follow how it works. Maybe Yonik can help. There was also a bug in fcontext preventing caching the weight. There is a reflection hack in it for now (nocommit)

This patch also fixes:
- Solr's BoostedQuery was fixed, too

I still dont like the name of the protected method in IndexSearcher createWeight(), as it does more than that. It rewrites, creates the weight and then normalizes the query. I would like to rename it and make it maybe public, but expert only.

For 3.x I would do the rename, too, and use VirtualMethod to fix invocations by 3rd party code if overridden.

> Move Query.weight() to IndexSearcher as protected method
> --------------------------------------------------------
>
>                 Key: LUCENE-3208
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3208
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/search
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3208.patch
>
>
> We had this issue several times, latest in LUCENE-3207.
> The method Query.weight() was left in Query for backwards reasons in Lucene 2.9 when we changed Weight class. This method is only to be called on top-level queries - and this is done by IndexSearcher. This method is just a utility method, that has nothing to do with the query itsself (it just combines the createWeight method and calls the normalization afterwards). 
> The problem we have is that any query that wraps other queries (like CustomScore, ConstantScore, Boolean) calls Query.weight() instead of Query.createWeight(), it will do normalization two times, leading to strange bugs.
> For 3.3 I will make Query.weight() simply delegate to IndexSearcher's replacement method with a big deprecation warning, so user sees this. In IndexSearcher itsself the method will be protected to only be called by itsself or subclasses of IndexSearcher. Delegation for backwards is no problem, as protected is accessible by classes in same package.
> I would suggest the method name to be IndexSearcher.createNormalizedWeight(Query q)

--
This message is automatically generated by JIRA.
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