Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-1689

XPath and union queries with "or" can return the same node multiple times

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 1.0
    • query
    • None

    Description

      XPath queries that contain "or" with can in some cases return the same node twice. Those queries are converted to "union", as follows, where the same problem exists:

      select [jcr:path], [jcr:score], * from ... 
      where contains(*, 'square') 
      union 
      select [jcr:path], [jcr:score], * from ... 
      where [x] = '1'
      

      Currently, the results of both subqueries are combined with "Iterators.concat(left.getRows(), right.getRows())" (Iterators is from Google Guava). That means results of the first part of the union is executed, then the result of the second query. This result is wrapped / filtered using "FilterIterators.newCombinedFilter(it, distinct, limit, offset, orderBy, settings)", which is Oak code. "distinct" is true for "union" and false for "union all".

      Now, "distinct" operates on the result row object, which contains the path, the score, and all property values. In previous versions, the "jcr:score" was always a fixed value, but in the latest Oak version "jcr:score" is the value returned from the index, which means the two rows are not equal:

      path: /test/a, score: 0.5 (from the first subquery; Lucene index)
      path: /test/a, score: 0.0 (from the second subquery; property index)
      

      Attachments

        Issue Links

          Activity

            People

              thomasm Thomas Mueller
              thomasm Thomas Mueller
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: