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

rep:facet returns wrong results for complex queries



    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.7
    • Fix Version/s: None
    • Component/s: lucene
    • Labels:


      eComplex queries in that case are queries, which are passed to lucene not containing all original constraints. For example queries with multiple path restrictions like:

      select [rep:facet(simple/tags)] from [nt:base] as a where contains(a.[*], 'ipsum') and (isdescendantnode(a,'/content1') or isdescendantnode(a,'/content2'))

      In that particular case the index planer gives ":fulltext:ipsum" to lucene even though the index supports evaluating path constraints.

      As counting the facets happens on the raw result of lucene, the returned facets are incorrect. For example having the following content

       + text = lorem ipsum
       - simple/
        + tags = tag1, tag2
       + text = lorem ipsum
       - simple/
        + tags = tag1, tag2
       + text = lorem ipsum
       - simple/
         + tags = tag1, tag2

      the expected result for the dimensions of simple/tags and the query above is

      • tag1: 2
      • tag2: 2

      as the result set is 2 results long and all documents are equal. The actual result set is

      • tag1: 3
      • tag2: 3

      as the path constraint is not handled by lucene.

      To workaround that the only solution that came to my mind is building the disjunctive normal form of my complex query and executing a query for each of the disjunctive statements. As this is expanding exponentially its only a theoretical solution, nothing for production.


        1. restrictionPropagationTest.patch
          3 kB
          Dirk Rudolph
        2. facetsInMultipleRoots.patch
          5 kB
          Dirk Rudolph



            • Assignee:
              diru Dirk Rudolph
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: