Thomas Mueller created OAK-1689:
-----------------------------------

             Summary: XPath and union queries with "or" can return the same 
node multiple times
                 Key: OAK-1689
                 URL: https://issues.apache.org/jira/browse/OAK-1689
             Project: Jackrabbit Oak
          Issue Type: Bug
          Components: query
            Reporter: Thomas Mueller
            Assignee: Thomas Mueller


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:

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

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:

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




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to