I want to index two different OntModel and execute sparql queries on them. For example:
String query = "PREFIX fise: <http://fise.iks-project.eu/ontology/>\n"
+ "PREFIX pf: <http://jena.hpl.hp.com/ARQ/property#>\n"
+ "PREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n"
+ "SELECT distinct ?def\n" + "WHERE {\n"
+ " ?item a skos:Concept .\n"
+ " ?item skos:definition ?def.\n"
+ " (?label ?score) pf:textMatch 'someKeyword'. \n"
+ "};
ResultSet result = QueryExecutionFactory.create(query, ontModel1).execSelect();
ResultSet result2 = QueryExecutionFactory.create(query, ontModel2).execSelect();
How can I create different indexes for the two ont models or should I do that? Eventually, what I need is to query the two ont models using LARQ features.
As far as I understand to be able to use lucene features in while executing SPARQL, we need to implement a code like the following one.
IndexBuilderString larqBuilder = new IndexBuilderString();
larqBuilder.indexStatements(ontModel.listStatements());
IndexLARQ index = larqBuilder.getIndex();
LARQ.setDefaultIndex(index);
But this code allows setting a single index. Furthermore, I don't want to merge two ont models. There is a Concext concept but I didn't get how to use it.
It seems the answer is registering indexes per-query execution using the context of query.
QueryExecution qe = QueryExecutionFactory.create(query, model) ;
LARQ.setDefaultIndex(qe.getContext(), index) ;