Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7808

PayloadScoreQuery and SpanPayloadCheckQuery have incomplete .equals and .hashCode methods

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0, 6.6
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Both PayloadScoreQuery and SpanPayloadCheckQuery have incomplete .equals and .hashCode methods, causing caching issues.

      1. LUCENE-7808.patch
        13 kB
        Erik Hatcher
      2. LUCENE-7808.patch
        10 kB
        Erik Hatcher
      3. LUCENE-7808.patch
        9 kB
        Erik Hatcher

        Activity

        Hide
        ehatcher Erik Hatcher added a comment -

        (initially failing) tests and implementation fixes

        Show
        ehatcher Erik Hatcher added a comment - (initially failing) tests and implementation fixes
        Hide
        romseygeek Alan Woodward added a comment -
        • Can you use Objects.hash() for the hashcode implementations?
        • SpanPayloadCheckQuery.rewrite() needs to rewrite its inner query as well (see LUCENE-7481)

        Otherwise +1

        Show
        romseygeek Alan Woodward added a comment - Can you use Objects.hash() for the hashcode implementations? SpanPayloadCheckQuery.rewrite() needs to rewrite its inner query as well (see LUCENE-7481 ) Otherwise +1
        Hide
        ehatcher Erik Hatcher added a comment -

        Alan Woodward thanks for feedback. I did use Objects.hash() in the .hashCode's that I worked on - is that not quite correct? As for rewrite() - I'm not sure what is needed there exactly. For some reason I added a .rewrite to SpanPayloadCheckQuery, but not to PayloadScoreQuery - but I guess I didn't do that fully? Do you have an example or some other hints as to how to implement what is needed? Happy to do the work while I'm in there!

        Show
        ehatcher Erik Hatcher added a comment - Alan Woodward thanks for feedback. I did use Objects.hash() in the .hashCode's that I worked on - is that not quite correct? As for rewrite() - I'm not sure what is needed there exactly. For some reason I added a .rewrite to SpanPayloadCheckQuery, but not to PayloadScoreQuery - but I guess I didn't do that fully? Do you have an example or some other hints as to how to implement what is needed? Happy to do the work while I'm in there!
        Hide
        ehatcher Erik Hatcher added a comment -

        Alan Woodward - I think I'm getting warmer. I implemented this (currently failing) test:

          public void testRewrite() throws IOException {
            SpanMultiTermQueryWrapper fou = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term("field", "fou*")));
            SpanMultiTermQueryWrapper fiv = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term("field", "fiv*")));
        
            SpanNearQuery sq = new SpanNearQuery(new SpanQuery[] {fou, fiv}, 0, true);
        
            List<BytesRef> payloads = new ArrayList<>();
            payloads.add(new BytesRef("pos: 0"));
            BytesRef payload2 = new BytesRef("pos: 1");
        
            SpanPayloadCheckQuery query = new SpanPayloadCheckQuery(sq, payloads);
        
            checkHits(query, new int[]{1});
          }
        

        The above errors with "java.lang.IllegalArgumentException: Rewrite first!".

        Show
        ehatcher Erik Hatcher added a comment - Alan Woodward - I think I'm getting warmer. I implemented this (currently failing) test: public void testRewrite() throws IOException { SpanMultiTermQueryWrapper fou = new SpanMultiTermQueryWrapper( new WildcardQuery( new Term( "field" , "fou*" ))); SpanMultiTermQueryWrapper fiv = new SpanMultiTermQueryWrapper( new WildcardQuery( new Term( "field" , "fiv*" ))); SpanNearQuery sq = new SpanNearQuery( new SpanQuery[] {fou, fiv}, 0, true ); List<BytesRef> payloads = new ArrayList<>(); payloads.add( new BytesRef( "pos: 0" )); BytesRef payload2 = new BytesRef( "pos: 1" ); SpanPayloadCheckQuery query = new SpanPayloadCheckQuery(sq, payloads); checkHits(query, new int []{1}); } The above errors with "java.lang.IllegalArgumentException: Rewrite first!".
        Hide
        ehatcher Erik Hatcher added a comment -

        fix for SpanPayloadCheckQuery's rewrite+test - solves LUCENE-7481

        Show
        ehatcher Erik Hatcher added a comment - fix for SpanPayloadCheckQuery's rewrite+test - solves LUCENE-7481
        Hide
        ehatcher Erik Hatcher added a comment -

        Alan Woodward - I fumbled for a moment, but think I understand the rewrite issue and have made a test and fix in my latest patch. I imagine that PayloadScoreQuery needs the same treatment, so I'll tackle that as well here.

        Show
        ehatcher Erik Hatcher added a comment - Alan Woodward - I fumbled for a moment, but think I understand the rewrite issue and have made a test and fix in my latest patch. I imagine that PayloadScoreQuery needs the same treatment, so I'll tackle that as well here.
        Hide
        ehatcher Erik Hatcher added a comment -

        this patch adds the rewrite to PayloadScoreQuery too, along with test. ready to commit to cover this JIRA and LUCENE-7481

        Show
        ehatcher Erik Hatcher added a comment - this patch adds the rewrite to PayloadScoreQuery too, along with test. ready to commit to cover this JIRA and LUCENE-7481
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 28aeeadb5f5d3ba74823da00250398b0a80a6ec1 in lucene-solr's branch refs/heads/master from Erik Hatcher
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=28aeead ]

        LUCENE-7808: Fix PayloadScoreQuery and SpanPayloadCheckQuery .equals and .hashCode methods.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 28aeeadb5f5d3ba74823da00250398b0a80a6ec1 in lucene-solr's branch refs/heads/master from Erik Hatcher [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=28aeead ] LUCENE-7808 : Fix PayloadScoreQuery and SpanPayloadCheckQuery .equals and .hashCode methods.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 64caf176ba92beeadf6856bfeac5cf8043d8251b in lucene-solr's branch refs/heads/master from Erik Hatcher
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=64caf17 ]

        LUCENE-7481: fix rewrite methods
        LUCENE-7808: fix .equals/.hashCode methods

        Show
        jira-bot ASF subversion and git services added a comment - Commit 64caf176ba92beeadf6856bfeac5cf8043d8251b in lucene-solr's branch refs/heads/master from Erik Hatcher [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=64caf17 ] LUCENE-7481 : fix rewrite methods LUCENE-7808 : fix .equals/.hashCode methods
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit de0ae56b6232ebc2edb3b1084a4f6f3de4cc8ba4 in lucene-solr's branch refs/heads/branch_6x from Erik Hatcher
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=de0ae56 ]

        LUCENE-7808: Fix PayloadScoreQuery and SpanPayloadCheckQuery .equals and .hashCode methods.

        Show
        jira-bot ASF subversion and git services added a comment - Commit de0ae56b6232ebc2edb3b1084a4f6f3de4cc8ba4 in lucene-solr's branch refs/heads/branch_6x from Erik Hatcher [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=de0ae56 ] LUCENE-7808 : Fix PayloadScoreQuery and SpanPayloadCheckQuery .equals and .hashCode methods.

          People

          • Assignee:
            ehatcher Erik Hatcher
            Reporter:
            ehatcher Erik Hatcher
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development