Clone URL (Committers only):
https://cms.apache.org/redirect?new=anonymous;action=diff;uri=http://jena.apache.org/documentation%2Fquery%2Ftext-query.mdtext
Chris Tomlinson
Index: trunk/content/documentation/query/text-query.mdtext
===================================================================
--- trunk/content/documentation/query/text-query.mdtext (revision 1819918)
+++ trunk/content/documentation/query/text-query.mdtext (working copy)
@@ -228,10 +228,11 @@
?s text:query (rdfs:label 'protégé' 'lang:fr') # restrict search to
French
(?s ?score) text:query 'word' # query capturing also
the score
(?s ?score ?literal) text:query 'word' # ... and original
literal value
+ (?s ?score ?literal ?g) text:query 'word' # ... and the graph
The most general form is:
- (?s ?score ?literal) text:query (property 'query string' limit 'lang:xx')
+ (?s ?score ?literal ?g) text:query (property 'query string' limit
'lang:xx')
#### Input arguments:
@@ -268,17 +269,15 @@
| subject URI | The subject of the indexed RDF triple. |
| score | (optional) The score for the match. |
| literal | (optional) The matched object literal. |
+| graph URI | (optional) The graph URI of the triple. |
The results include the _subject URI_; the _score_ assigned by the
text search engine; and the entire matched _literal_ (if the index has
been [configured to store literal values](#text-dataset-assembler)).
The _subject URI_ may be a variable, e.g., `?s`, or a _URI_. In the
latter case the search is restricted to triples with the specified
-subject. The _score_ and the _literal_ **must** be variables.
+subject. The _score_, _literal_ and _graph URI_ **must** be variables.
-If only the _subject_ variable, `?s` is needed then it **must be** written
without
-surrounding `( )`; otherwise, an error is signalled.
-
### Query strings
There are several points that need to be considered when formulating
@@ -401,6 +400,17 @@
graph ?g { ?s a ex:Item } .
}
+Further, if `tdb:unionDefaultGraph true` 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 `text:query`:
+
+ select ?g ?s ?lit
+ where {
+ (?s ?sc ?lit ?g) text:query "zorn" .
+ }
+
+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
_documents_ carry
+the containing graph URI for free as it were.
+
#### Queries across multiple `Field`s
As mentioned earlier, the text index uses the