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

SpanPayloadCheckQuery and PayloadScoreQuery are missing rewrite methods

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 6.6, 7.0
    • None
    • None
    • New

    Description

      If used with a wildcard query, the result is a failure saying: "Rewrite query first"

      The SpanNearQuery has the rewrite method; however the SpanPayloadCheckQuery just returns the query itself.

      this works:

      ```
      spanNear([vectrfield:ebyuugz, SpanMultiTermQueryWrapper(vectrfield:e*), SpanMultiTermQueryWrapper(vectrfield:m*), SpanMultiTermQueryWrapper(vectrfield:f*)], 0, true)
      ```

      code to generate the query:

      ```
      private Query getSpanQuery(String[] parts, int howMany, boolean truncate) throws UnsupportedEncodingException {
      SpanQuery[] clauses = new SpanQuery[howMany+1];
      clauses[0] = new SpanTermQuery(new Term("vectrfield", parts[0])); // surname
      for (int i = 0; i < howMany; i++) {
      if (truncate)

      { SpanMultiTermQueryWrapper<WildcardQuery> q = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("vectrfield", parts[i+1].substring(0, 1) + "*"))); clauses[i+1] = q; }

      else

      { clauses[i+1] = new SpanTermQuery(new Term("vectrfield", parts[i+1])); }

      }
      SpanNearQuery sq = new SpanNearQuery(clauses, 0, true); // match in order
      return sq;
      }
      ```

      and this fails:

      ```
      spanPayCheck(spanNear([vectrfield:ebyuugz, SpanMultiTermQueryWrapper(vectrfield:e*), SpanMultiTermQueryWrapper(vectrfield:m*), SpanMultiTermQueryWrapper(vectrfield:f*)], 1, true), payloadRef: 0;1;2;3
      ```

      each clause is made of:

      ```
      new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("vectrfield", parts[i+1].substring(0, 1) + "*")));
      ```

      It is a regression; the code was working well in SOLR4.x

      Attachments

        Activity

          People

            ehatcher Erik Hatcher
            rchyla Roman Chyla
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: