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

Lucene suggestions index definition can't be restricted to a specific type of node

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 1.2.14, 1.3.9, 1.4
    • lucene
    • None

    Description

      While performing a suggestor query like

      SELECT [rep:suggest()] as suggestion  FROM [nt:unstructured] WHERE suggest('foo')
      

      Suggestor does not provide any result. In current implementation, suggestions in Oak work only for index definitions for nt:base nodetype.
      So, an index definition like:

          <lucene-suggest
              jcr:primaryType="oak:QueryIndexDefinition"
              async="async"
              compatVersion="{Long}2"
              type="lucene">
              <indexRules jcr:primaryType="nt:unstructured">
                  <nt:base jcr:primaryType="nt:unstructured">
                      <properties jcr:primaryType="nt:unstructured">
                          <description
                              jcr:primaryType="nt:unstructured"
                              analyzed="{Boolean}true"
                              name="description"
                              propertyIndex="{Boolean}true"
                              useInSuggest="{Boolean}true"/>
                      </properties>
                  </nt:base>
              </indexRules>
          </lucene-suggest>
      

      works, but if we change nodetype to nt:unstructured like:

          <lucene-suggest
              jcr:primaryType="oak:QueryIndexDefinition"
              async="async"
              compatVersion="{Long}2"
              type="lucene">
              <indexRules jcr:primaryType="nt:unstructured">
                  <nt:unstructured jcr:primaryType="nt:unstructured">
                      <properties jcr:primaryType="nt:unstructured">
                          <description
                              jcr:primaryType="nt:unstructured"
                              analyzed="{Boolean}true"
                              name="description"
                              propertyIndex="{Boolean}true"
                              useInSuggest="{Boolean}true"/>
                      </properties>
                  </nt:base>
              </indexRules>
          </lucene-suggest>
      

      , it won't work.

      The issue is that suggestor implementation essentially is passing a pseudo row with path=/.:

      LucenePropertyIndex.java
          private boolean loadDocs() {
      ...
                              queue.add(new LuceneResultRow(suggestedWords));
      ...
      

      and

      LucenePropertyIndex.java
              LuceneResultRow(Iterable<String> suggestWords) {
                  this.path = "/";
                  this.score = 1.0d;
                  this.suggestWords = suggestWords;
              }
      

      Due to path being set to "/", SelectorImpl later filters out the result as rep:root (primary type of "/") isn't a nt:unstructured.

      Attachments

        1. LuceneIndexSuggestionTest.java
          9 kB
          Vikas Saurabh
        2. OAK-3156.patch
          20 kB
          Vikas Saurabh
        3. OAK-3156-take2.patch
          16 kB
          Vikas Saurabh

        Issue Links

          Activity

            People

              teofili Tommaso Teofili
              catholicon Vikas Saurabh
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: