Thomas Mueller created OAK-7256:

             Summary: Query: option to wait for indexes to be updated
                 Key: OAK-7256
             Project: Jackrabbit Oak
          Issue Type: Improvement
          Components: query
            Reporter: Thomas Mueller
             Fix For: 1.10

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 

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:

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 

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,...).

This message was sent by Atlassian JIRA

Reply via email to