Hi, Adam's gave me the right direction.
I managed to load my function class in fuseki config using ja:loadClass but now remains the following issue (the function is not registered)see fuseki logs : [2017-12-26 16:10:13] exec WARN URI <http://purl.bdrc.io/functio ns#MyFilterFunction> has no registered function factory How can I register this function now that I have the code available on the endpoint side ? Thanks for helping Marc. Le mardi 26 décembre 2017 à 17:43 +0000, Andy Seaborne a écrit : > As well s Adam's point (and all the libraries your function needs, > transitively) > > What is in the Fuseki log file? > How was the data loaded into Fuseki? > > >> I printed out the > >> FunctionRegistry > > And > > On 26/12/17 14:51, ajs6f wrote: > > I'm not as familiar with the extension points of ARQ as I would > > like to be, but as I understand what you are doing, you are > > registering a new function with your _local_ registry, then firing > > a query at a _remote_ endpoint (which has a completely independent > > registry in a different JVM in a different process, potentially in > > a different _system_). > > > > The query is getting interpreted and executed by that remote > > service, not locally. So you need to register the function _there_. > > > > Take a look at this thread: > > > > https://lists.apache.org/thread.html/1cda23332af4264883e88697d99460 > > 5770edcde2f93ddea51240e4b8@%3Cusers.jena.apache.org%3E > > > > It should get you started as to how to register extension > > functionality in Fuseki. > > > > > > Adam Soroka > > > > > On Dec 26, 2017, at 9:34 AM, Marc Agate <agate.m...@gmail.com> > > > wrote: > > > > > > Hi ! > > > > > > I successfully implemented sparql queries using custom ARQ > > > functions > > > using the following (custom function code): > > > > > > **************** > > > public class LevenshteinFilter extends FunctionBase2 { > > > > > > public LevenshteinFilter() { super() ; } > > > > > > public NodeValue exec(NodeValue value1, NodeValue value2){ > > > LevenshteinDistance LD=new LevenshteinDistance(); > > > int i = LD.apply(value1.asString(), value2.asString()); > > > return NodeValue.makeInteger(i); > > > } > > > } > > > *************** > > > > > > it works fine when I query against a Model loaded from a turtle > > > file, > > > like this: > > > > > > *************** > > > InputStream input = > > > QueryProcessor.class.getClassLoader().getResourceAsStream("full.t > > > tl"); > > > model = > > > ModelFactory.createMemModelMaker().createModel("default"); > > > model.read(input,null,"TURTLE"); // null base URI, > > > since > > > model URIs are absolute > > > input.close(); > > > *************** > > > > > > with the query being sent like this : > > > > > > *************** > > > String functionUri = "http://www.example1.org/LevenshteinFunction > > > "; > > > FunctionRegistry.get().put(functionUri , > > > LevenshteinFilter.class); > > > > > > String s = "whatever you want"; > > > String sparql = prefixes+" SELECT DISTINCT ?l WHERE { ?x > > > rdfs:label ?l . " + "FILTER(fct:LevenshteinFunction(?l, \"" + s > > > + "\") > > > < 4) }"; > > > Query query = QueryFactory.create(sparql); > > > QueryExecution qexec = > > > QueryExecutionFactory.create(query, > > > model); > > > ResultSet rs = qexec.execSelect(); > > > *************** > > > > > > However, if i use a working fuseki endpoint for the same dataset > > > (full.ttl) like this : > > > > > > *************** > > > fusekiUrl="http://localhost:3030/ds/query"; > > > *************** > > > > > > sending the query like this (using > > > QueryExecutionFactory.sparqlService(fusekiUrl,query) instead of > > > QueryExecutionFactory.create(query,model) ): > > > > > > *************** > > > String functionUri = "http://www.example1.org/LevenshteinFunction > > > "; > > > FunctionRegistry.get().put(functionUri , > > > LevenshteinFilter.class); > > > > > > String s = "whatever you want"; > > > String sparql = prefixes+" SELECT DISTINCT ?l WHERE { ?x > > > rdfs:label ?l . " + "FILTER(fct:LevenshteinFunction(?l, \"" + s + > > > "\") > > > < 4) }"; > > > Query query = QueryFactory.create(sparql); > > > QueryExecution qexec = > > > QueryExecutionFactory.sparqlService(fusekiUrl,query); > > > ResultSet rs = qexec.execSelect(); > > > *************** > > > > > > Then I don't get any results back. In both cases I printed out > > > the > > > FunctionRegistry and they contain exactly the same entries, > > > especially > > > : > > > > > > key=http://www.example1.org/LevenshteinFunction value: > > > org.apache.jena.sparql.function.FunctionFactoryAuto@5a45133e > > > > > > Any clue ? > > > > > > Thanks