You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Maria Jackson <ma...@gmail.com> on 2015/04/07 23:36:01 UTC
Executing queries in Jena
I tried to run the following query in Jena:
./tdbquery --time --loc=test1/ "select ?a?c?d (?c + ?d as ?score)
where{graph ?g{?a <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a <score1>
?d}} order by ?score"
------------------------------------------------------------------------------
| a | c | d | score |
==============================================================================
| <s> | 729 | "805"^^</km^2> | |
| <s1> | 729 | "805"^^</km^2> | |
| <s2> | 729 | "805"^^</km^2> | |
------------------------------------------------------------------------------
Although I am able to obtain the values of ?c and ?d, but the value of
?score is NULL. From what I understand it may be because of different
units. But if I want to rank my results based on the linear sum of the
scores of facts, then how can I do that in Jena?
Re: Executing queries in Jena
Posted by Andy Seaborne <an...@apache.org>.
On 08/04/15 00:57, Maria Jackson wrote:
> Oops still it gives me the output as:
>
> ------------------------------------------------------------------------------
> | a | c | d | score |
> ==============================================================================
> | <s> | 729 | "805"^^</km^2> | |
> | <s1> | 729 | "805"^^</km^2> | |
> | <s2> | 729 | "805"^^</km^2> | |
> ------------------------------------------------------------------------------
>
"805"^^</km^2> is not a number. It's a literal with an unknown datatype.
(123 + "foo"^^<unknown> AS ?X)
is an unbound ?X
To convert to qa number, try getting the lexical form and casting:
xsd:decimal(str("805"^^</km^2>))
Also ^ is illegal in URIs.
Andy
> That is, still it does not display the value of ?score.
>
>
> On Wed, Apr 8, 2015 at 5:22 AM, Maria Jackson <ma...@gmail.com>
> wrote:
>
>> Ok. Thank you. Just to confirm do you mean I should use it like:
>>
>> ./tdbquery --time --loc=test1/ "select ?a?c?d ?score where{graph ?g{?a
>> <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a <score1> ?d} bind (?c +
>> ?d as ?score)} order by ?score"
>>
>> On Wed, Apr 8, 2015 at 5:12 AM, Miguel Bento Alves <mb...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> You should use bind:
>>> select ?a ?c ?d ?score
>>> where{
>>> ...
>>> bind (?c + ?d as ?score)
>>> }
>>>
>>>
>>> MBA
>>>
>>>> On 07 Apr 2015, at 22:36, Maria Jackson <ma...@gmail.com>
>>> wrote:
>>>>
>>>> I tried to run the following query in Jena:
>>>>
>>>> ./tdbquery --time --loc=test1/ "select ?a?c?d (?c + ?d as ?score)
>>>> where{graph ?g{?a <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a
>>> <score1>
>>>> ?d}} order by ?score"
>>>>
>>>>
>>> ------------------------------------------------------------------------------
>>>> | a | c | d | score |
>>>>
>>> ==============================================================================
>>>> | <s> | 729 | "805"^^</km^2> | |
>>>> | <s1> | 729 | "805"^^</km^2> | |
>>>> | <s2> | 729 | "805"^^</km^2> | |
>>>>
>>> ------------------------------------------------------------------------------
>>>>
>>>> Although I am able to obtain the values of ?c and ?d, but the value of
>>>> ?score is NULL. From what I understand it may be because of different
>>>> units. But if I want to rank my results based on the linear sum of the
>>>> scores of facts, then how can I do that in Jena?
>>>
>>>
>>
>
Re: Executing queries in Jena
Posted by Maria Jackson <ma...@gmail.com>.
Oops still it gives me the output as:
------------------------------------------------------------------------------
| a | c | d | score |
==============================================================================
| <s> | 729 | "805"^^</km^2> | |
| <s1> | 729 | "805"^^</km^2> | |
| <s2> | 729 | "805"^^</km^2> | |
------------------------------------------------------------------------------
That is, still it does not display the value of ?score.
On Wed, Apr 8, 2015 at 5:22 AM, Maria Jackson <ma...@gmail.com>
wrote:
> Ok. Thank you. Just to confirm do you mean I should use it like:
>
> ./tdbquery --time --loc=test1/ "select ?a?c?d ?score where{graph ?g{?a
> <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a <score1> ?d} bind (?c +
> ?d as ?score)} order by ?score"
>
> On Wed, Apr 8, 2015 at 5:12 AM, Miguel Bento Alves <mb...@gmail.com>
> wrote:
>
>> Hi,
>>
>> You should use bind:
>> select ?a ?c ?d ?score
>> where{
>> ...
>> bind (?c + ?d as ?score)
>> }
>>
>>
>> MBA
>>
>> > On 07 Apr 2015, at 22:36, Maria Jackson <ma...@gmail.com>
>> wrote:
>> >
>> > I tried to run the following query in Jena:
>> >
>> > ./tdbquery --time --loc=test1/ "select ?a?c?d (?c + ?d as ?score)
>> > where{graph ?g{?a <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a
>> <score1>
>> > ?d}} order by ?score"
>> >
>> >
>> ------------------------------------------------------------------------------
>> > | a | c | d | score |
>> >
>> ==============================================================================
>> > | <s> | 729 | "805"^^</km^2> | |
>> > | <s1> | 729 | "805"^^</km^2> | |
>> > | <s2> | 729 | "805"^^</km^2> | |
>> >
>> ------------------------------------------------------------------------------
>> >
>> > Although I am able to obtain the values of ?c and ?d, but the value of
>> > ?score is NULL. From what I understand it may be because of different
>> > units. But if I want to rank my results based on the linear sum of the
>> > scores of facts, then how can I do that in Jena?
>>
>>
>
Re: Executing queries in Jena
Posted by Maria Jackson <ma...@gmail.com>.
Ok. Thank you. Just to confirm do you mean I should use it like:
./tdbquery --time --loc=test1/ "select ?a?c?d ?score where{graph ?g{?a <name>
?b} graph ?g1{?a <score2> ?c} graph ?g2{?a <score1> ?d} bind (?c + ?d as
?score)} order by ?score"
On Wed, Apr 8, 2015 at 5:12 AM, Miguel Bento Alves <mb...@gmail.com>
wrote:
> Hi,
>
> You should use bind:
> select ?a ?c ?d ?score
> where{
> ...
> bind (?c + ?d as ?score)
> }
>
>
> MBA
>
> > On 07 Apr 2015, at 22:36, Maria Jackson <ma...@gmail.com>
> wrote:
> >
> > I tried to run the following query in Jena:
> >
> > ./tdbquery --time --loc=test1/ "select ?a?c?d (?c + ?d as ?score)
> > where{graph ?g{?a <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a
> <score1>
> > ?d}} order by ?score"
> >
> >
> ------------------------------------------------------------------------------
> > | a | c | d | score |
> >
> ==============================================================================
> > | <s> | 729 | "805"^^</km^2> | |
> > | <s1> | 729 | "805"^^</km^2> | |
> > | <s2> | 729 | "805"^^</km^2> | |
> >
> ------------------------------------------------------------------------------
> >
> > Although I am able to obtain the values of ?c and ?d, but the value of
> > ?score is NULL. From what I understand it may be because of different
> > units. But if I want to rank my results based on the linear sum of the
> > scores of facts, then how can I do that in Jena?
>
>
Re: Executing queries in Jena
Posted by Miguel Bento Alves <mb...@gmail.com>.
Hi,
You should use bind:
select ?a ?c ?d ?score
where{
...
bind (?c + ?d as ?score)
}
MBA
> On 07 Apr 2015, at 22:36, Maria Jackson <ma...@gmail.com> wrote:
>
> I tried to run the following query in Jena:
>
> ./tdbquery --time --loc=test1/ "select ?a?c?d (?c + ?d as ?score)
> where{graph ?g{?a <name> ?b} graph ?g1{?a <score2> ?c} graph ?g2{?a <score1>
> ?d}} order by ?score"
>
> ------------------------------------------------------------------------------
> | a | c | d | score |
> ==============================================================================
> | <s> | 729 | "805"^^</km^2> | |
> | <s1> | 729 | "805"^^</km^2> | |
> | <s2> | 729 | "805"^^</km^2> | |
> ------------------------------------------------------------------------------
>
> Although I am able to obtain the values of ?c and ?d, but the value of
> ?score is NULL. From what I understand it may be because of different
> units. But if I want to rank my results based on the linear sum of the
> scores of facts, then how can I do that in Jena?