You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/05/30 10:18:55 UTC

[GitHub] [lucene] chlorochrule opened a new pull request #160: LUCENE-9823: Fix not to rewrite boosted single term SynonymQuery

chlorochrule opened a new pull request #160:
URL: https://github.com/apache/lucene/pull/160


   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Lucene:
   
   * https://issues.apache.org/jira/projects/LUCENE
   
   You will need to create an account in Jira in order to create an issue.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * LUCENE-####: <short description of problem or changes>
   
   LUCENE must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   > When rewriting a SynonymQuery with a single term, we create a BoostQuery wrapping a TermQuery. 
   
   However, 
   
   >  it now multiplies the final TermQuery score instead of multiplying the term frequency before it's passed to the score calculation.
   
   JIRA: https://issues.apache.org/jira/browse/LUCENE-9823
   
   # Solution
   
   Remove unsafe codes.
   
   # Tests
   
   All existing tests ensure.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/lucene/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [x] ~I have created a Jira issue and added the issue ID to my pull request title.~ **I've picked newdev ticket**
   - [x] I have given Lucene maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
     - No tests are added. Because, I removed unsafe optimization.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [lucene] jtibshirani merged pull request #160: LUCENE-9823: Fix not to rewrite boosted single term SynonymQuery

Posted by GitBox <gi...@apache.org>.
jtibshirani merged pull request #160:
URL: https://github.com/apache/lucene/pull/160


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [lucene] chlorochrule commented on pull request #160: LUCENE-9823: Fix not to rewrite boosted single term SynonymQuery

Posted by GitBox <gi...@apache.org>.
chlorochrule commented on pull request #160:
URL: https://github.com/apache/lucene/pull/160#issuecomment-853248112


   Thanks for explaining and reviewing again!
   I fixed :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [lucene] chlorochrule commented on pull request #160: LUCENE-9823: Fix not to rewrite boosted single term SynonymQuery

Posted by GitBox <gi...@apache.org>.
chlorochrule commented on pull request #160:
URL: https://github.com/apache/lucene/pull/160#issuecomment-853065004


   Thanks for reviewing, @jtibshirani !
   I added `TestSynonymQuery#testRewrite` and fixed the same problem of `CombinedFieldQuery`. I may not fully understand the meaning of:
   > The same consideration affects CombinedFieldQuery in sandbox.
   
   If the fix of bc85a2a is  incorrect, please explain what is the same consideration. 
   
   Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [lucene] jtibshirani merged pull request #160: LUCENE-9823: Fix not to rewrite boosted single term SynonymQuery

Posted by GitBox <gi...@apache.org>.
jtibshirani merged pull request #160:
URL: https://github.com/apache/lucene/pull/160


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [lucene] jtibshirani commented on a change in pull request #160: LUCENE-9823: Fix not to rewrite boosted single term SynonymQuery

Posted by GitBox <gi...@apache.org>.
jtibshirani commented on a change in pull request #160:
URL: https://github.com/apache/lucene/pull/160#discussion_r644158197



##########
File path: lucene/core/src/test/org/apache/lucene/search/TestSynonymQuery.java
##########
@@ -466,4 +467,26 @@ public void testRandomTopDocs() throws IOException {
     reader.close();
     dir.close();
   }
+
+  public void testRewrite() throws IOException {
+    // zero length SynonymQuery is rewritten
+    SynonymQuery q = new SynonymQuery.Builder("f").build();

Review comment:
       A small comment: in most other rewrite tests (like `TestBoostQuery#testRewrite`) we check the higher-level call `IndexSearcher#rewrite`. It'd be nice to do this to be consistent and to exercise the full rewrite logic.

##########
File path: lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
##########
@@ -237,14 +236,6 @@ public Query rewrite(IndexReader reader) throws IOException {
     if (fieldTerms.length == 1) {

Review comment:
       I like the simplification below of removing the rewrite to synonym query (which is not perfectly accurate). I think we also need to fix or remove this check `if (fieldTerms.length == 1) { ... }`, since it's only accurate when the field weight is 1.0f.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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