title: JCR query to return excerpt and parent identifier
body: <p>I would like to query the jackrabbit repository on the versions I have stored. </p>
  
  <p>My repository looks like the following:</p>
  
  <p><a href="https://i.stack.imgur.com/8ySfv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ySfv.png" alt="JCR repo structure"></a></p>
  
  <p>Following xpath query works well:<code>//element(*, nt:frozenNode)[jcr:contains(., '" + keyword + "') ]/rep:excerpt(.)</code> and from the Row object returned I can get the excerpt found in the de:template nodes 'de:content' property (for this to be full-text indexable I have my own lucene configuration).</p>
  
  <p>The problem however is: how to know what elements excerpt is found for, since the query only returns me the path found (/jcr:system/jcr:versionStorage/95/c8/3e/95c83efc-8441-4017-b3af-ae7be49f07e5/1.0/jcr:frozenNode/de:template) and the excerpt itself.</p>
  
  <p>So I would like to know the <strong>identifier</strong> of the nt:versionHistory node, as stored in Jackrabbit.</p>
  
  <p>I have a solution for this as well, by getting the parent nodes until the nt:versionHistory is reached and getting its identifier: </p>
  
  <pre><code>Row row = (Row) rows.next();
  Node node = row.getNode();
  Node frozenNode = node.getParent();
  Node versionNumber = frozenNode.getParent();
  String versionId = versionNumber.getIdentifier();
  </code></pre>
  
  <p>However this takes too much time and with lots of versions its bad for the performance. </p>
  
  <p><a href="https://i.stack.imgur.com/QtEHC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QtEHC.png" alt="Profiling JCR Query and getting nodes"></a></p>
  
  <p>Therefore, I wonder if it's possible to include this version id in the query, such that no parent nodes need to be fetched after the query is executed.</p>