AGFederationFreetextSearch.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGFederationFreetextSearch {
@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 ts1 = ags.renew("store1", AGPaths.TRIPLE_STORES);
AllegroGraph ts2 = ags.renew("store2", AGPaths.TRIPLE_STORES);
AllegroGraph[] parts = {ts1,ts2};
AllegroGraph fed = ags.federate("federationfreetext", parts, true);
ts1.registerFreetextPredicate("<http://www.w3.org/2000/01/rdf-schema#comment>");
ts2.registerFreetextPredicate("<http://www.w3.org/2000/01/rdf-schema#comment>");
ts1.addStatement("\"Jans\"", "!rdfs:comment", "\"Born in Emmen in the Netherlands\"");
ts2.addStatement("\"Gary\"", "!rdfs:comment", "\"Born in Springfield in the USA\"");
ts2.addStatement("\"Henk\"", "!rdfs:label", "\"Born in Emmermeer in the Netherlands\"");
ValueObject[] v = fed.getFreetextUniqueSubjects("(and 'emmen' 'born')");
AGUtils.printObjectArray("Subjects matching search: (and 'emmen' 'born')", v);
Cursor cc = fed.getFreetextStatements("(and 'emmen' 'born')");
AGUtils.showTriples(cc);
fed.closeTripleStore();
ts1.closeTripleStore();
ts2.closeTripleStore();
ags.disable();
}
}
Up |
Next