You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Alex To <to...@gmail.com> on 2019/09/06 04:08:08 UTC

Jena Lucene full text search return no results

Hi

 I created a Jena Lucene index with this configuration

var entDef = new EntityDefinition(
        "uri",
        "label",
        "graph", RDFS.label.asNode());
entDef.setLangField("lang");
entDef.setUidField("uid");


Then I loaded schema.org ontology and queried using Lucene API directly on
the index directory, I got expected result

QueryParser parser = new QueryParser("label", analyzer);
Query query = parser.parse("tax~");

But if I use Jena query, I got no result

ParameterizedSparqlString q = new ParameterizedSparqlString(
        "SELECT ?s WHERE { " +
                "   ?s text:query 'Taxi' " +
                "}");

q.setNsPrefix("text", "http://jena.apache.org/text#");


A minimal project to illustrate the problem can be found here
https://github.com/AlexTo/jena-lab/blob/master/src/main/java/com/company/MainSearch.java

If you run index() and then searchLucene() you can see expected results but
if you run searchJena() you see nothing. What did I miss??

Thank you

Best Regards

Re: Jena Lucene full text search return no results

Posted by Alex To <to...@gmail.com>.
I figured it out, I need to include GRAPH ?g in the query

Thanks

On Fri, Sep 6, 2019 at 2:08 PM Alex To <to...@gmail.com> wrote:

>
> Hi
>
>  I created a Jena Lucene index with this configuration
>
> var entDef = new EntityDefinition(
>         "uri",
>         "label",
>         "graph", RDFS.label.asNode());
> entDef.setLangField("lang");
> entDef.setUidField("uid");
>
>
> Then I loaded schema.org ontology and queried using Lucene API directly
> on the index directory, I got expected result
>
> QueryParser parser = new QueryParser("label", analyzer);
> Query query = parser.parse("tax~");
>
> But if I use Jena query, I got no result
>
> ParameterizedSparqlString q = new ParameterizedSparqlString(
>         "SELECT ?s WHERE { " +
>                 "   ?s text:query 'Taxi' " +
>                 "}");
>
> q.setNsPrefix("text", "http://jena.apache.org/text#");
>
>
> A minimal project to illustrate the problem can be found here
> https://github.com/AlexTo/jena-lab/blob/master/src/main/java/com/company/MainSearch.java
>
> If you run index() and then searchLucene() you can see expected results
> but if you run searchJena() you see nothing. What did I miss??
>
> Thank you
>
> Best Regards
>


-- 

Alex To

PhD Candidate

School of Computer Science

Knowledge Discovery and Management Research Group

Faculty of Engineering & IT

THE UNIVERSITY OF SYDNEY | NSW | 2006

Desk 4e69 | Building J12| 1 Cleveland Street

M. +61423330656 <%2B61450061602>