还是在同一个项目中,当我尝试用jena和sparql运行文本搜索时遇到了一个问题。错误描述说:
Exception in thread "main" org.apache.jena.query.QueryParseException: Encountered " "." ". "" at line 2, column 53.
我认为问题来自于询问。查询代码如下:
public static void queryData(Dataset dataset){
String prefix = "PREFIX email: <" + App.URI_PREFIX+">" +
"PREFIX text: <http://jena.apache.org/text#>";
long startTime = System.nanoTime();
System.out.println("Email's content contains 'good'");
String query = "SELECT * WHERE " +
"{ ?s text:query (email:content 'good'." +
" ?s email:content ?text . " +
" }" ;
dataset.begin(ReadWrite.READ);
try {
Query q = QueryFactory.create(prefix+"\n"+query);
QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
QueryExecUtils.executeQuery(q, qexec);
}finally { dataset.end();}
long finishTime = System.nanoTime();
double time = (finishTime-startTime)/1.0e6;
System.out.println ("Query "+String.format("FINISH - %.2fms", time));
startTime = System.nanoTime();
System.out.println("Email's content contains 'bad'");
query = "SELECT * WHERE" +
"{ (?s ?score ?lit) text:query (email:content 'bad' \"highlight:s:<em class='hiLite'> | e:</em>\") ." +
" ?s email:content ?text . " +
" }" ;
dataset.begin(ReadWrite.READ);
try {
Query q = QueryFactory.create(prefix+"\n"+query);
QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
QueryExecUtils.executeQuery(q, qexec);
} finally { dataset.end() ; }
finishTime = System.nanoTime();
time = (finishTime-startTime)/1.0e6;
System.out.println("Query "+String.format("FINISH - %.2fms", time));
}`
它是否需要更改查询代码,特别是在sparql中?请告诉我。谢谢您
暂无答案!
目前还没有任何答案,快来回答吧!