You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by bu...@apache.org on 2018/01/11 10:00:22 UTC

svn commit: r1023640 - in /websites/staging/jena/trunk/content: ./ documentation/query/text-query.html

Author: buildbot
Date: Thu Jan 11 10:00:21 2018
New Revision: 1023640

Log:
Staging update by buildbot for jena

Modified:
    websites/staging/jena/trunk/content/   (props changed)
    websites/staging/jena/trunk/content/documentation/query/text-query.html

Propchange: websites/staging/jena/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Jan 11 10:00:21 2018
@@ -1 +1 @@
-1820004
+1820850

Modified: websites/staging/jena/trunk/content/documentation/query/text-query.html
==============================================================================
--- websites/staging/jena/trunk/content/documentation/query/text-query.html (original)
+++ websites/staging/jena/trunk/content/documentation/query/text-query.html Thu Jan 11 10:00:21 2018
@@ -371,11 +371,12 @@ points below.</p>
 ?<span class="n">s</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> <span class="p">(</span><span class="n">rdfs</span><span class="p">:</span><span class="n">label</span> <span class="s">&#39;protégé&#39;</span> <span class="s">&#39;lang:fr&#39;</span><span class="p">)</span>    # <span class="n">restrict</span> <span class="n">search</span> <span class="n">to</span> <span class="n">French</span>
 <span class="p">(</span>?<span class="n">s</span> ?<span class="n">score</span><span class="p">)</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> <span class="s">&#39;word&#39;</span>                     # <span class="n">query</span> <span class="n">capturing</span> <span class="n">also</span> <span class="n">the</span> <span class="n">score</span>
 <span class="p">(</span>?<span class="n">s</span> ?<span class="n">score</span> ?<span class="n">literal</span><span class="p">)</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> <span class="s">&#39;word&#39;</span>            # <span class="p">...</span> <span class="n">and</span> <span class="n">original</span> <span class="n">literal</span> <span class="n">value</span>
+<span class="p">(</span>?<span class="n">s</span> ?<span class="n">score</span> ?<span class="n">literal</span> ?<span class="n">g</span><span class="p">)</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> <span class="s">&#39;word&#39;</span>         # <span class="p">...</span> <span class="n">and</span> <span class="n">the</span> <span class="n">graph</span>
 </pre></div>
 
 
 <p>The most general form is:</p>
-<div class="codehilite"><pre> <span class="p">(</span>?<span class="n">s</span> ?<span class="n">score</span> ?<span class="n">literal</span><span class="p">)</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> <span class="p">(</span><span class="n">property</span> <span class="s">&#39;query string&#39;</span> <span class="n">limit</span> <span class="s">&#39;lang:xx&#39;</span><span class="p">)</span>
+<div class="codehilite"><pre> <span class="p">(</span>?<span class="n">s</span> ?<span class="n">score</span> ?<span class="n">literal</span> ?<span class="n">g</span><span class="p">)</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> <span class="p">(</span><span class="n">property</span> <span class="s">&#39;query string&#39;</span> <span class="n">limit</span> <span class="s">&#39;lang:xx&#39;</span><span class="p">)</span>
 </pre></div>
 
 
@@ -440,6 +441,10 @@ language tag via <code>"lang:none"</code
 <td>literal</td>
 <td>(optional) The matched object literal.</td>
 </tr>
+<tr>
+<td>graph URI</td>
+<td>(optional) The graph URI of the triple.</td>
+</tr>
 </tbody>
 </table>
 <p>The results include the <em>subject URI</em>; the <em>score</em> assigned by the
@@ -447,9 +452,7 @@ text search engine; and the entire match
 been <a href="#text-dataset-assembler">configured to store literal values</a>).
 The <em>subject URI</em> may be a variable, e.g., <code>?s</code>, or a <em>URI</em>. In the
 latter case the search is restricted to triples with the specified
-subject. The <em>score</em> and the <em>literal</em> <strong>must</strong> be variables.</p>
-<p>If only the <em>subject</em> variable, <code>?s</code> is needed then it <strong>must be</strong> written without 
-surrounding <code>( )</code>; otherwise, an error is signalled.</p>
+subject. The <em>score</em>, <em>literal</em> and <em>graph URI</em> <strong>must</strong> be variables.</p>
 <h3 id="query-strings">Query strings<a class="headerlink" href="#query-strings" title="Permanent link">&para;</a></h3>
 <p>There are several points that need to be considered when formulating
 SPARQL queries using the Lucene interface. As mentioned above, in the case of Lucene the <code>query string</code> syntax is restricted to <code>Terms</code>, <code>Term modifiers</code>, <code>Boolean Operators</code> applied to <code>Terms</code>, and <code>Grouping</code> of terms. </p>
@@ -570,6 +573,17 @@ it may be more performant to express the
 </pre></div>
 
 
+<p>Further, if <code>tdb:unionDefaultGraph true</code> for a TDB dataset backing a Lucene index then it is possible to retrieve the graphs that contain triples resulting from a Lucene search via the fourth output argument to <code>text:query</code>:</p>
+<div class="codehilite"><pre><span class="n">select</span> ?<span class="n">g</span> ?<span class="n">s</span> ?<span class="n">lit</span>
+<span class="n">where</span> <span class="p">{</span>
+  <span class="p">(</span>?<span class="n">s</span> ?<span class="n">sc</span> ?<span class="n">lit</span> ?<span class="n">g</span><span class="p">)</span> <span class="n">text</span><span class="p">:</span><span class="n">query</span> &quot;<span class="n">zorn</span>&quot; <span class="p">.</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>This will generally perform much better than either of the previous approaches when there are
+large numbers of graphs since the Lucene search will run once and the returned <em>documents</em> carry
+the containing graph URI for free as it were.</p>
 <h4 id="queries-across-multiple-fields">Queries across multiple <code>Field</code>s<a class="headerlink" href="#queries-across-multiple-fields" title="Permanent link">&para;</a></h4>
 <p>As mentioned earlier, the text index uses the
 <a href="http://lucene.apache.org/core/6_4_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description">native Lucene query language</a>;