Hi Sergey,

Yes, your suggestion works for me. I do not know which between Virtuoso and
Jena is following the correct semantics of SPARQL, but I will follow the
more constrained (~=precise) semantics of Virtuoso.

Thank you!


With regards,
Jason Koh
cseweb.ucsd.edu/~jbkoh

On Thu, Jan 25, 2018 at 7:26 AM, Sergey Malinin <sergmali...@gmail.com>
wrote:

> Hi Jason,
>
> In you sources:
> >         Query sparql = QueryFactory.create(qStr);
> >         VirtuosoQueryExecution vqd = 
> > VirtuosoQueryExecutionFactory.create(sparql,
> graph);
>
> Based on this, SPARQL query will be parsed by Jena ARQ and after this, it
> will be converted back to String before send to Virtuoso.
> Therefore Jena ARQ could change your original query a little.
> You could check it with something:
>
>     String qStr = "PREFIX base: <http://base.org#> PREFIX xsd: <
> http://www.w3.org/2001/XMLSchema#>  SELECT ?s {?s base:name
> \"test_sensor\"^^xsd:string}";
>     Query sparql = QueryFactory.create(qStr);
>     System.out.println(sparql.toString());
>
> The output log will be:
> -----------------------------------------
> PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>
> PREFIX  base: <http://base.org#>
>
> SELECT  ?s
> WHERE
>   { ?s  base:name  "test_sensor" }
> -----------------------------------------
>
> You could see, that Jena ARQ changed your query text a little, so it
> doesn't work as expected.
>
>
> I offer change you code like:
>
> -         Query sparql = QueryFactory.create(qStr);
> -         VirtuosoQueryExecution vqd = 
> VirtuosoQueryExecutionFactory.create(sparql,
> graph);
> +
> +         VirtuosoQueryExecution vqd = 
> VirtuosoQueryExecutionFactory.create(qStr,
> graph);
>
> so your query will not be changed by Jena ARQ.
>
>
>
> On 01/25/2018 07:42 AM, Jason Koh wrote:
>
>> Dear Hugh and the community,
>>
>> I have created a regenerator repository: https://github.com/jbkoh/virtj
>> ena_regenerator
>>
>> If available, please review the problem. I think it's the problem of Virt
>> Jena, your feedback would be much useful for me to write the right code.
>>
>> Thanks!
>>
>>
>> With regards,
>> Jason Koh
>> cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/~jbkoh>
>>
>> On Tue, Jan 23, 2018 at 12:50 PM, Jason Koh <jb...@eng.ucsd.edu <mailto:
>> jb...@eng.ucsd.edu>> wrote:
>>
>>     Forgot to clarify the configuration:
>>
>>     Ubuntu 16.04 (64bit)
>>     Virtuoso 7.2.4.2
>>     Virtuoso Jean: virt_jena3
>>     Virtuodo JDBC: virtjdbc4
>>     Java: openjdk version "1.8.0_151"
>>
>>     Thank you.
>>
>>
>>     With regards,
>>     Jason Koh
>>     cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/~jbkoh>
>>
>>     On Tue, Jan 23, 2018 at 12:46 PM, Jason Koh <jb...@eng.ucsd.edu
>> <mailto:jb...@eng.ucsd.edu>> wrote:
>>
>>         Here's the Java code snippet not working:
>>         ```java
>>         String nameStr = "test_sensor1";
>>         String BASE = "http://base.org#";;
>>         String uuid = "xxxxx";
>>         Node name = NodeFactory.createLiteralByValue(nameStr, XSDstring);
>>         Node point = NodeFactory.createURI(BASE + uuid);
>>         Node hasName = NodeFactory.createURI(BASE + "name");
>>         graph.add(new Triple(point, hasName, name));
>>         String qStr =
>>              "PREFIX base: <http://base.org#>\n" +
>>              "SELECT ?s WHERE {\n" +
>>              "?s base:name \"test_sensor1\" . \n" +
>>              "}";
>>         Query sparql = QueryFactory.create(qStr);
>>         VirtuosoQueryExecution vqd = 
>> VirtuosoQueryExecutionFactory.create(sparql,
>> graph);
>>         ResultSet results = vqd.execSelect();
>>         while (results.hasNext()) {
>>            QuerySolution result = results.nextSolution();
>>            System.out.println(result.get("s").toString());
>>         }
>>         System.out.println("Done");
>>            }
>>         ```
>>
>>         The value ``results`` is empty and this code does not print
>> anything. I can make a regenerator. Let me know if that helps.
>>
>>
>>         With regards,
>>         Jason Koh
>>         cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/~jbkoh>
>>
>>         On Tue, Jan 23, 2018 at 12:16 PM, Jason Koh <jb...@eng.ucsd.edu
>> <mailto:jb...@eng.ucsd.edu>> wrote:
>>
>>             Hi Hugh,
>>
>>             I inserted the tripled through /Virtuoso Jena/ and I can see
>> triples like
>>             ``ex:xxxx    base:name    test_sensor0``
>>             when I query just with ?s ?p ?o. However, I don't get any
>> result with ``?s base:name "test_sensor0"``.
>>
>>             As you showed, it works with command line insertions. Let me
>> verify the source of the problem once again and come back.
>>
>>             Thank you!
>>
>>
>>             With regards,
>>             Jason Koh
>>             cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/~jbkoh>
>>
>>
>>             On Tue, Jan 23, 2018 at 3:17 AM, Hugh Williams <
>> hwilli...@openlinksw.com <mailto:hwilli...@openlinksw.com>> wrote:
>>
>>                 Hi Jason,
>>
>>                 What exactly is not working for you ? As the following
>> works for me:
>>
>>                 SQL> SPARQL PREFIX base: <base> INSERT DATA { GRAPH <koh>
>> { <1> base:name "sensor1" . } };
>>
>>                 Done. -- 1 msec.
>>                 SQL> SPARQL SELECT * FROM <koh> WHERE {?s ?p ?o};
>>                 s
>>                          p
>>                                                o
>>                 LONG VARCHAR
>>                         LONG VARCHAR
>>                                               LONG VARCHAR
>>                 ______________________________
>> _________________________________________________
>>
>>                 1
>>                          basename
>>                                                 sensor1
>>
>>                 1 Rows. -- 2 msec.
>>                 SQL> SPARQL PREFIX base: <base> SELECT ?s {?s base:name
>> "sensor1"};
>>                 s
>>                 LONG VARCHAR
>>                 ______________________________
>> _________________________________________________
>>
>>                 1
>>
>>                 1 Rows. -- 1 msec.
>>                 SQL> SPARQL PREFIX base: <base> SELECT ?g ?s {GRAPH ?g
>> {?s base:name "sensor1"}};
>>                 g
>>                          s
>>                 LONG VARCHAR
>>                         LONG VARCHAR
>>                 ______________________________
>> _________________________________________________
>>
>>                 koh
>>                          1
>>
>>                 1 Rows. -- 1 msec.
>>                 SQL>
>>
>>
>>                 Best Regards
>>                 Hugh Williams
>>                 Professional Services
>>                 OpenLink Software, Inc.      //
>> http://www.openlinksw.com/
>>                 Weblog   -- http://www.openlinksw.com/blogs/ <
>> http://www.openlinksw.com/blogs/>
>>                 LinkedIn -- http://www.linkedin.com/compan
>> y/openlink-software/ <http://www.linkedin.com/company/openlink-software/>
>>                 Twitter  -- http://twitter.com/OpenLink
>>                 Google+  -- http://plus.google.com/100570109519069333827/
>> <http://plus.google.com/100570109519069333827/>
>>                 Facebook -- http://www.facebook.com/OpenLinkSoftware <
>> http://www.facebook.com/OpenLinkSoftware>
>>                 Universal Data Access, Integration, and Management
>> Technology Providers
>>
>>
>>
>>                  > On 23 Jan 2018, at 09:58, Jason Koh <
>> jb...@eng.ucsd.edu <mailto:jb...@eng.ucsd.edu>> wrote:
>>                  >
>>                  > Hi Kingsley,
>>                  >
>>                  > Thanks for the prompt response. I just tried it and it
>> works well. I haven't compared the performance yet but wish the string
>> match is faster.
>>                  >
>>                  > However, I am having trouble querying with the String
>> Literal with SPARQL. The following query does not work for Virtuoso.
>>                  > ```sparql
>>                  > select ?s {
>>                  >   ?s base:name "sensor1". # also tried
>> "sensor1"^^xsd:string but the same result.
>>                  > }
>>                  > ```
>>                  > This query returns empty result.
>>                  >
>>                  > If I query with no pattern (?s ?p ?o), I can see the
>> following triple:
>>                  > :xxxx base:name "sensor1",
>>                  >
>>                  > Can't sort out the problem. Do you have any ideas on
>> this?
>>                  >
>>                  > Thank you!
>>                  >
>>                  >
>>                  >
>>                  >
>>                  >
>>                  > With regards,
>>                  > Jason Koh
>>                  > cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/~jbkoh>
>>                  >
>>                  > On Mon, Jan 22, 2018 at 2:52 PM, Kingsley Idehen <
>> kide...@openlinksw.com <mailto:kide...@openlinksw.com>> wrote:
>>                  > On 1/22/18 5:11 PM, Jason Koh wrote:
>>                  >> Hi there,
>>                  >>
>>                  >> I am trying to use Virtuoso for metadata of
>> city-scale sensor database. (metroinsight.io <http://metroinsight.io>).
>>                  >>
>>                  >> I wonder if there is a way to optimize certain SPARQL
>> query pattern. I often query this:
>>                  >> ```sparql
>>                  >> select ?s where {
>>                  >>   ?s base:name ex:mySensor1 .
>>                  >> }
>>                  >> ```
>>                  >>
>>                  >> I could optimize it by caching those with Redis or
>> else, but I wonder if I can force indexing "name" properties in Virtuoso.
>>                  >>
>>                  >> Thank you!
>>                  >>
>>                  >>
>>                  >> With regards,
>>                  >> Jason Koh
>>                  >> cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/~jbkoh
>> >
>>                  >
>>                  > Have you looked at text indexing in Virtuoso with
>> regards to SPARQL?
>>                  > [1] http://docs.openlinksw.com/vir
>> tuoso/rdfsparqlrulefulltext/ <http://docs.openlinksw.com/vi
>> rtuoso/rdfsparqlrulefulltext/> .
>>                  > --
>>                  > Regards,
>>                  >
>>                  > Kingsley Idehen
>>                  > Founder & CEO
>>                  > OpenLink Software   (Home Page:
>>                  > http://www.openlinksw.com
>>                  > )
>>                  >
>>                  > Weblogs (Blogs):
>>                  > Legacy Blog:
>>                  > http://www.openlinksw.com/blog/~kidehen/ <
>> http://www.openlinksw.com/blog/~kidehen/>
>>                  >
>>                  > Blogspot Blog:
>>                  > http://kidehen.blogspot.com
>>                  >
>>                  > Medium Blog:
>>                  > https://medium.com/@kidehen
>>                  >
>>                  >
>>                  > Profile Pages:
>>                  > Pinterest:
>>                  > https://www.pinterest.com/kidehen/ <
>> https://www.pinterest.com/kidehen/>
>>                  >
>>                  > Quora:
>>                  > https://www.quora.com/profile/Kingsley-Uyi-Idehen <
>> https://www.quora.com/profile/Kingsley-Uyi-Idehen>
>>                  >
>>                  > Twitter:
>>                  > https://twitter.com/kidehen
>>                  >
>>                  > Google+:
>>                  > https://plus.google.com/+KingsleyIdehen/about <
>> https://plus.google.com/+KingsleyIdehen/about>
>>                  >
>>                  > LinkedIn:
>>                  > http://www.linkedin.com/in/kidehen <
>> http://www.linkedin.com/in/kidehen>
>>                  >
>>                  >
>>                  > Web Identities (WebID):
>>                  > Personal:
>>                  > http://kingsley.idehen.net/pub
>> lic_home/kidehen/profile.ttl#i <http://kingsley.idehen.net/pu
>> blic_home/kidehen/profile.ttl#i>
>>                  >
>>                  >         :
>>                  > http://id.myopenlink.net/DAV/h
>> ome/KingsleyUyiIdehen/Public/kingsley.ttl#this
>>                 <http://id.myopenlink.net/DAV/
>> home/KingsleyUyiIdehen/Public/kingsley.ttl#this>
>>                  >
>>                  >
>>                  >
>>                  >
>>                  > ------------------------------
>> ------------------------------------------------
>>                  > Check out the vibrant tech community on one of the
>> world's most
>>                  > engaging tech sites, Slashdot.org!
>> http://sdm.link/slashdot
>>                  > _______________________________________________
>>                  > Virtuoso-users mailing list
>>                  > Virtuoso-users@lists.sourceforge.net <mailto:
>> Virtuoso-users@lists.sourceforge.net>
>>                  > https://lists.sourceforge.net/
>> lists/listinfo/virtuoso-users <https://lists.sourceforge.net
>> /lists/listinfo/virtuoso-users>
>>                  >
>>                  >
>>                  > ------------------------------
>> ------------------------------------------------
>>                  > Check out the vibrant tech community on one of the
>> world's most
>>                  > engaging tech sites, Slashdot.org!
>> http://sdm.link/slashdot_______________________________________________
>>                 <http://sdm.link/slashdot_____
>> __________________________________________>
>>                  > Virtuoso-users mailing list
>>                  > Virtuoso-users@lists.sourceforge.net <mailto:
>> Virtuoso-users@lists.sourceforge.net>
>>                  > https://lists.sourceforge.net/
>> lists/listinfo/virtuoso-users <https://lists.sourceforge.net
>> /lists/listinfo/virtuoso-users>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>
>>
>>
>> _______________________________________________
>> Virtuoso-users mailing list
>> Virtuoso-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/virtuoso-users
>>
>>
>
> --
> Best Regards,
> Sergey Malinin
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to