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

IndexOutOfBoundsException when sorting by jcr:score + field

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.5.14, 1.6.0
    • Component/s: lucene
    • Labels:
      None
    • Environment:

      AEM 6.1, 6.2

      Description

      The quert written in jackrabbit sort by not working with oak. Samples order by which fails is [0] & stack trace at [2]. If I change the sort [1] it works & issue reproducible on any oak branch also, Additional This happens only with custom index definition. The exact query & index definition at [3].

      [0]

      order by @jcr:score descending, post/@pubDate descending
      order by  @jcr:score,post/@pubDate descending
      

      [1]

      order by  post/@pubDate descending,@jcr:score descending
      

      [2]

      java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
      at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      at java.util.ArrayList.get(ArrayList.java:429)
      at org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner$PlanResult.getOrderedProperty(IndexPlanner.java:540)
      at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.getSort(LucenePropertyIndex.java:605)
      at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.query(LucenePropertyIndex.java:281)
      at org.apache.jackrabbit.oak.query.ast.SelectorImpl.execute(SelectorImpl.java:329)
      at org.apache.jackrabbit.oak.query.QueryImpl$RowIterator.fetchNext(QueryImpl.java:769)
      at org.apache.jackrabbit.oak.query.QueryImpl$RowIterator.hasNext(QueryImpl.java:798)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at com.google.common.collect.Iterators$5.hasNext(Iterators.java:542)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.fetchNext(FilterIterators.java:137)
      at org.apache.jackrabbit.oak.query.FilterIterators$DistinctIterator.hasNext(FilterIterators.java:151)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.init(FilterIterators.java:203)
      at org.apache.jackrabbit.oak.query.FilterIterators$SortIterator.hasNext(FilterIterators.java:237)
      at org.apache.jackrabbit.oak.jcr.query.QueryResultImpl$3.fetch(QueryResultImpl.java:181)
      at org.apache.jackrabbit.oak.jcr.query.QueryResultImpl$3.<init>(QueryResultImpl.java:176)
      at org.apache.jackrabbit.oak.jcr.query.QueryResultImpl.getNodes(QueryResultImpl.java:170)
      at com.adobe.granite.queries.impl.explain.query.ExplainQueryServlet.executionTimes(ExplainQueryServlet.java:331)
      

      [3]

      /jcr:root/content//element(*, cq:PageContent)
      [(jcr:contains(post/@headingText, 'geometrixx') 
      or jcr:contains(jcr:title, 'geometrixx') 
      or jcr:contains(pageTitle, 'geometrixx') 
      or jcr:contains(title, 'geometrixx') 
      or jcr:contains(cq:tags, 'geometrixx') 
      or jcr:contains(post/@subheadingText, 'geometrixx') 
      or jcr:contains(post/par/*, 'geometrixx') 
      or jcr:contains(post/@authorName, 'geometrixx'))] 
      order by @jcr:score descending, post/@pubDate descending
      
      {  
         "jcr:primaryType":"oak:QueryIndexDefinition",
         "compatVersion":2,
         "type":"lucene",
         "async":"async",
         "evaluatePathRestrictions":true,
         "excludedPaths":[  
            "/jcr:system",
            "/etc",
            "/var"
         ],
         "reindex":false,
         "reindexCount":5,
         "aggregates":{  
            "jcr:primaryType":"nt:unstructured",
            "cq:PageContent":{  
               "jcr:primaryType":"nt:unstructured",
               "postParsys":{  
                  "jcr:primaryType":"nt:unstructured",
                  "relativeNode":true,
                  "path":"post/par/*/richText"
               },
               "include3":{  
                  "jcr:primaryType":"nt:unstructured",
                  "relativeNode":true,
                  "path":"cq:tags"
               },
               "include2":{  
                  "jcr:primaryType":"nt:unstructured",
                  "relativeNode":true,
                  "path":"title"
               },
               "include1":{  
                  "jcr:primaryType":"nt:unstructured",
                  "relativeNode":true,
                  "path":"pageTitle"
               },
               "include0":{  
                  "jcr:primaryType":"nt:unstructured",
                  "relativeNode":true,
                  "path":"jcr:title"
               }
            }
         },
         "indexRules":{  
            "jcr:primaryType":"nt:unstructured",
            "cq:PageContent":{  
               "jcr:primaryType":"nt:unstructured",
               "properties":{  
                  "jcr:primaryType":"nt:unstructured",
                  "postHeadingText":{  
                     "jcr:primaryType":"nt:unstructured",
                     "analyzed":true,
                     "name":"post/headingText",
                     "type":"String"
                  },
                  "postSubHeadingText":{  
                     "jcr:primaryType":"nt:unstructured",
                     "analyzed":true,
                     "name":"post/subheadingText",
                     "type":"String"
                  },
                  "postAuthorName":{  
                     "jcr:primaryType":"nt:unstructured",
                     "analyzed":true,
                     "name":"post/authorName",
                     "type":"String"
                  },
                  "pubDate":{  
                     "jcr:primaryType":"nt:unstructured",
                     "ordered":true,
                     "direction":"descending",
                     "name":"post/pubDate",
                     "type":"Date"
                  }
               }
            }
         }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              thomasm Thomas Mueller
              Reporter:
              schikkeg Sham
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: