This project has retired. For details please refer to its Attic page.
Apache Marmotta - SPARQL Full-Text Extension

SPARQL Full-Text Extension

Full-text search works over the literal values of nodes and differs from normal literal queries or regexp filters in that it applies language-specific lingustic processing (e.g. stemming and stop-word elimination).

Full-text search currently offers two SPARQL functions that can be used in the FILTER part of a query and return boolean values (found or not found):

Note that full-text search is only available when using backend databases that support this functionality (currently only PostgreSQL and MySQL). Only PostgreSQL has real support for language specific processing. Also note that performance heavily depends on the availability of an appropriate full-text index in the database. The KiWi SPARQL module will automatically create full-text indexes for the languages configured in the KiWiConfiguration used for creating the triple store.

The KiWi SPARQL module comes with its own these extensions:

PREFIX mm: <http://marmotta.apache.org/vocabulary/sparql-functions#>

The following example searches for the word “software” occurring in the dc:description field of the resource using the literal language of dc:description:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mm: <http://marmotta.apache.org/vocabulary/sparql-functions#>

SELECT ?p1 ?fn ?age WHERE {
    ?p1 foaf:name ?fn .
    ?p1 foaf:age ?age .
    ?p1 dc:description ?desc .
    FILTER( mm:fulltext-search(str(?desc), "software", lang(?desc)) )
}