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

Query: option to wait for indexes to be updated

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: query
    • Labels:
      None

      Description

      Sometimes (rarely, but still) queries should include the very latest changes, even if the index is updated asynchronously. For example when running unit test: data is added, and then a query is run to check if the data is there. The problem with asynchronous indexes is, you don't know exactly how long you have to wait. Often the index is updated quickly, and sometimes it takes a few seconds.

      What about extending the query syntax as follows:

      Wait for all indexes (no matter which index is used for this query) - this would be used rarely, just for testing:

      /jcr:root/* 
      option(wait for all indexes timeout 60)
      

      Wait for just those indexes (well, usually it's just one, but sometimes it's multiple) that are needed for the given query. This query could also be used in an application that strictly needs the very latest results, even for fulltext queries. The "timeout" would mean "wait at most 10 seconds, and if not up-to-date then throw an exeption", while "max 10" would mean "wait at most 10 seconds, but still run the query in any case".

      /jcr:root/content//*[jcr:contains(., 'hello')] 
      option(wait for indexes max 10)
      

      The query would wait, and once the indexes are up-to-date, return the requested result.

      So the syntax is (both SQL-2 and XPath):

      <query> option(wait for [all] indexes 
        { max | timeout } <numberOfSeconds> 
        [, <otherOptions> ] )
      

      So other options can also be used (option traversal fail,...).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: