AGSparqlFreetextSearch.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGSparqlFreetextSearch {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("kennedy", AGPaths.TRIPLE_STORES);
ts.registerFreetextPredicate("<http://example.org/kennedy/first-name>");
AGUtils.loadNTriplesWithTiming(ts,AGPaths.dataSources("kennedy.ntriples"));
ts.indexAllTriples(true);
String query =
"PREFIX ex: <http://example.org/kennedy/> " +
"PREFIX fti: <http://franz.com/ns/allegrograph/2.2/textindex/>" +
"SELECT ?fname ?lname " +
"WHERE { ?person fti:match 'Arnold' . " +
"?person ex:first-name ?fname . " +
"?person ex:last-name ?lname " +
"}";
AGUtils.doSparqlSelect(ts, query);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next