FYI your second example has mismatched brackets in the FILTER which leads to a SPARQL parser error once the underlying ParameterizedSparlString bug is fixed
Rob On 04/03/2018, 22:07, "[email protected]" <[email protected]> wrote: Here is a piece of code that illustrates the issue and its context described in my previous message : public static void main(String[] args){ String prefixes="PREFIX : <http://purl.bdrc.io/ontology/core/>\n" + " PREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n" + " PREFIX text: <http://jena.apache.org/text#>" ; HashMap<String,String> map=new HashMap<>(); map.put("L_name", "\"rgyud bla ma\""); map.put("LG_name", "bo-x-ewts"); String test1=prefixes+ "select ?comment (GROUP_CONCAT(DISTINCT ?comment_type; SEPARATOR=\" <>" + "\") AS ?comment_types) ?root_name\n" + "where {\n" + " (?root ?score ?root_name) text:query ?L_name .\n" + " ?comment :workIsAbout ?root;\n" + " :workGenre ?g .\n" + " ?g skos:prefLabel ?comment_type .\n" + "}\n"+ "group by ?comment ?root_name"; ParameterizedSparqlString queryStr = new ParameterizedSparqlString(test1); queryStr.setLiteral("L_name", map.get("L_name"),map.get("LG_name")); Query q1=queryStr.asQuery(); String test2=prefixes+ "select ?comment (GROUP_CONCAT(DISTINCT ?comment_type; SEPARATOR=\" <>" + "\") AS ?comment_types) ?root_name\n" + "where {\n" + " (?root ?score ?root_name) text:query ?L_name .\n" + " ?comment :workIsAbout ?root;\n" + " :workGenre ?g .\n" + " ?g skos:prefLabel ?comment_type .\n" + " FILTER ((contains(?comment_type, \"commentary\" ))\n" + "}\n" + "group by ?comment ?root_name"; ParameterizedSparqlString queryStr2 = new ParameterizedSparqlString(test2); queryStr2.setLiteral("L_name", map.get("L_name"),map.get("LG_name")); Query q2=queryStr2.asQuery(); } Marc
