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

Query: advanced fulltext search conditions


    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.15
    • Component/s: query
    • Labels:


      Currently, the query engine does not use a fulltext index if there are multiple fulltext conditions combined with "or". Also, the QueryIndex interface does not support boosts, and does not support fulltext conditions on properties (just on nodes) - Filter.getFulltextConditions is a collection of strings, combined with "and", but does not contain the information whether a condition is on a property or on all properties. Also, the popular sorting by score (specially descending) is not currently supported.

      Marcel Reutegger and me discussed how we could support those features (including boost) in a way that is backward compatible with Jackrabbit 2.x, but without adding a lot of complexity. Example Jackrabbit 2.x query:

        and (jcr:contains(jcr:content/@tags, 'it:blue') 
        or jcr:contains(jcr:content/@tags, '/tags/it/blue')))]
      /jcr:root/content//element(*, nt:hierarchyNode)[
        (jcr:contains(jcr:content, 'SomeTextToSearch') 
        or jcr:contains(jcr:content/@jcr:title, 'SomeTextToSearch') 
        or jcr:contains(jcr:content/@jcr:description, 'SomeTextToSearch'))]
        /rep:excerpt(.) order by @jcr:score descending 

      A possible solution is to extend the internal fulltext syntax to support those features. The internal fulltext syntax is the one used by
      Filter.getFulltextCondition (not the one used within the original XPath, SQL, or SQL-2 query). The proposed syntax (work in progress, just a rough draft so far) is:

      FullTextSearch ::= Or
        ['order by score' [' desc']]
      Or ::= And {' OR ' And}* 
      And ::= Term {' ' Term}*
      Term ::= '(' Or ')' | ['-'] SimpleTerm
      SimpleTerm ::= [Property ':'] '"' Word {' ' Word}* '"' ['^' Boost]
      Property ::= <property name>
      Boost ::= <number>

      The idea is that the syntax matches the syntax used by Lucene (except for the 'order by' part), so that the Lucene and Solr index implementations should get simpler (only need minimal parsing, possibly just the 'order by' part). Search terms (phrases, words) are always within double quotes. That means, the above queries would result in the following condition:

      OR jcr:content/tags:"/tags/it/blue"
      OR jcr:content/jcr:title:"SomeTextToSearch"
      OR jcr:content/jcr:description:"SomeTextToSearch"
      order by score desc

      It would also allow to switch back from

      Collection<String> getFulltextConditions()


      String getFulltextCondition()


          Issue Links



              • Assignee:
                tmueller Thomas Mueller
                tmueller Thomas Mueller
              • Votes:
                0 Vote for this issue
                3 Start watching this issue


                • Created: