You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Alexey Lef (JIRA)" <ji...@apache.org> on 2007/01/29 23:36:49 UTC

[jira] Created: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Custom similarity is ignored when using MultiSearcher
-----------------------------------------------------

                 Key: LUCENE-789
                 URL: https://issues.apache.org/jira/browse/LUCENE-789
             Project: Lucene - Java
          Issue Type: Bug
          Components: Search
    Affects Versions: 2.0.1
            Reporter: Alexey Lef


Symptoms:
I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.

Problem analysis:
The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.

Potential solution:
Adding the following line:
    cacheSim.setSimilarity(getSimilarity());
after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen updated LUCENE-789:
-------------------------------

    Lucene Fields: [Patch Available]  (was: [New])

> Custom similarity is ignored when using MultiSearcher
> -----------------------------------------------------
>
>                 Key: LUCENE-789
>                 URL: https://issues.apache.org/jira/browse/LUCENE-789
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.0.1
>            Reporter: Alexey Lef
>         Assigned To: Doron Cohen
>         Attachments: 789_patch.txt, TestMultiSearcherSimilarity.java
>
>
> Symptoms:
> I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.
> Problem analysis:
> The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.
> Potential solution:
> Adding the following line:
>     cacheSim.setSimilarity(getSimilarity());
> after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Posted by "Otis Gospodnetic (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486835 ] 

Otis Gospodnetic commented on LUCENE-789:
-----------------------------------------

Alexey, the best way to start with this, and the way that will help get this fixed in Lucene core is to write a unit test class that does what your code does with MultiSearcher and BooleanQuery, and shows that the test fails when a custom Similarity class is used.  You can make that custom Similarity an inner class in your unit test class, to contain everything neatly in a single class.

Once we see the test failing we cann apply your suggested fix and see if that works, if your previously broken unit test now passes, and if all other unit tests still pass.


> Custom similarity is ignored when using MultiSearcher
> -----------------------------------------------------
>
>                 Key: LUCENE-789
>                 URL: https://issues.apache.org/jira/browse/LUCENE-789
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.0.1
>            Reporter: Alexey Lef
>
> Symptoms:
> I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.
> Problem analysis:
> The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.
> Potential solution:
> Adding the following line:
>     cacheSim.setSimilarity(getSimilarity());
> after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen resolved LUCENE-789.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2

Fix committed, thanks Alexey!

It should be noted that as before this fix, creating a multiSearcher from Searchers for whom custom similarity was set has no effect - the custom similarities of those searchers are masked by the similarity of the MultiSearcher. This is as designed, because MultiSearcher operates on Searchables (not on Searchers).

> Custom similarity is ignored when using MultiSearcher
> -----------------------------------------------------
>
>                 Key: LUCENE-789
>                 URL: https://issues.apache.org/jira/browse/LUCENE-789
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.0.1
>            Reporter: Alexey Lef
>         Assigned To: Doron Cohen
>             Fix For: 2.2
>
>         Attachments: 789_patch.txt, TestMultiSearcherSimilarity.java
>
>
> Symptoms:
> I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.
> Problem analysis:
> The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.
> Potential solution:
> Adding the following line:
>     cacheSim.setSimilarity(getSimilarity());
> after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Assigned: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen reassigned LUCENE-789:
----------------------------------

    Assignee: Doron Cohen

> Custom similarity is ignored when using MultiSearcher
> -----------------------------------------------------
>
>                 Key: LUCENE-789
>                 URL: https://issues.apache.org/jira/browse/LUCENE-789
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.0.1
>            Reporter: Alexey Lef
>         Assigned To: Doron Cohen
>         Attachments: TestMultiSearcherSimilarity.java
>
>
> Symptoms:
> I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.
> Problem analysis:
> The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.
> Potential solution:
> Adding the following line:
>     cacheSim.setSimilarity(getSimilarity());
> after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Posted by "Doron Cohen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doron Cohen updated LUCENE-789:
-------------------------------

    Attachment: 789_patch.txt

Thanks for the test case, Alexey!

Problem was in MultiSearcher.CachedDfSource.
Attached patch fixes this in MultiSearcher, plus adds the test-case to existing MultiSearcherTest.



> Custom similarity is ignored when using MultiSearcher
> -----------------------------------------------------
>
>                 Key: LUCENE-789
>                 URL: https://issues.apache.org/jira/browse/LUCENE-789
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.0.1
>            Reporter: Alexey Lef
>         Assigned To: Doron Cohen
>         Attachments: 789_patch.txt, TestMultiSearcherSimilarity.java
>
>
> Symptoms:
> I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.
> Problem analysis:
> The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.
> Potential solution:
> Adding the following line:
>     cacheSim.setSimilarity(getSimilarity());
> after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-789) Custom similarity is ignored when using MultiSearcher

Posted by "Alexey Lef (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Lef updated LUCENE-789:
------------------------------

    Attachment: TestMultiSearcherSimilarity.java

Attached unit test

> Custom similarity is ignored when using MultiSearcher
> -----------------------------------------------------
>
>                 Key: LUCENE-789
>                 URL: https://issues.apache.org/jira/browse/LUCENE-789
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.0.1
>            Reporter: Alexey Lef
>         Attachments: TestMultiSearcherSimilarity.java
>
>
> Symptoms:
> I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.
> Problem analysis:
> The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.
> Potential solution:
> Adding the following line:
>     cacheSim.setSimilarity(getSimilarity());
> after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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