You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Mikael Pesonen <mi...@lingsoft.fi> on 2020/02/21 09:11:51 UTC

Problem with sparql bind

Hi,

I've got this query that first selects some resources (into ?s2), then 
gets all the resource triplets. BIND clause below is more complicated 
and i need to have the BIND there, but problem occurs with this 
simplified version too. So I'm expecting only the triplets for 5 
resources ?s2 but below query is returning all the triplets in graph 
https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0. 
I must have error somewhere but could not find any help googling. Any 
ideas? It has something to do with bind inside the graph.

CONSTRUCT { ?s ?p ?o }
WHERE
{
         {
                 SELECT DISTINCT ?s2 WHERE
                 {
                         GRAPH 
<https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
                         {
                                 ?s2 
<http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
                         }
                 }
                 OFFSET 0 LIMIT 5
         }

         GRAPH 
<https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
         {
             BIND (?s2 as ?s) ?s ?p ?o
         }
}



Moving bind outside graph works as intended:

CONSTRUCT { ?s ?p ?o }
WHERE
{
         {
                 SELECT DISTINCT ?s2 WHERE
                 {
                         GRAPH 
<https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
                         {
                                 ?s2 
<http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
                         }
                 }
                 OFFSET 0 LIMIT 5
         }
BIND (?s2 as ?s)
         GRAPH 
<https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
         {
              ?s ?p ?o
         }
}

Thanks,
Mikael


Re: Problem with sparql bind

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Yes. It's the bottom-up semantics.


On Fri, Feb 21, 2020 at 10:21 AM Mikael Pesonen
<mi...@lingsoft.fi> wrote:
>
>
> Okay so separate graph statements make the scopes too separate even if
> the graph is the same.
>
> Thanks Martynas!
>
> On 21/02/2020 11.16, Martynas Jusevičius wrote:
> > ?s2 is undefined in the second GRAPH.
> >
> > On Fri, Feb 21, 2020 at 10:12 AM Mikael Pesonen
> > <mi...@lingsoft.fi> wrote:
> >> Hi,
> >>
> >> I've got this query that first selects some resources (into ?s2), then
> >> gets all the resource triplets. BIND clause below is more complicated
> >> and i need to have the BIND there, but problem occurs with this
> >> simplified version too. So I'm expecting only the triplets for 5
> >> resources ?s2 but below query is returning all the triplets in graph
> >> https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0.
> >> I must have error somewhere but could not find any help googling. Any
> >> ideas? It has something to do with bind inside the graph.
> >>
> >> CONSTRUCT { ?s ?p ?o }
> >> WHERE
> >> {
> >>           {
> >>                   SELECT DISTINCT ?s2 WHERE
> >>                   {
> >>                           GRAPH
> >> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
> >>                           {
> >>                                   ?s2
> >> <http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
> >>                           }
> >>                   }
> >>                   OFFSET 0 LIMIT 5
> >>           }
> >>
> >>           GRAPH
> >> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
> >>           {
> >>               BIND (?s2 as ?s) ?s ?p ?o
> >>           }
> >> }
> >>
> >>
> >>
> >> Moving bind outside graph works as intended:
> >>
> >> CONSTRUCT { ?s ?p ?o }
> >> WHERE
> >> {
> >>           {
> >>                   SELECT DISTINCT ?s2 WHERE
> >>                   {
> >>                           GRAPH
> >> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
> >>                           {
> >>                                   ?s2
> >> <http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
> >>                           }
> >>                   }
> >>                   OFFSET 0 LIMIT 5
> >>           }
> >> BIND (?s2 as ?s)
> >>           GRAPH
> >> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
> >>           {
> >>                ?s ?p ?o
> >>           }
> >> }
> >>
> >> Thanks,
> >> Mikael
> >>
>
> --
> Lingsoft - 30 years of Leading Language Management
>
> www.lingsoft.fi
>
> Speech Applications - Language Management - Translation - Reader's and Writer's Tools - Text Tools - E-books and M-books
>
> Mikael Pesonen
> System Engineer
>
> e-mail: mikael.pesonen@lingsoft.fi
> Tel. +358 2 279 3300
>
> Time zone: GMT+2
>
> Helsinki Office
> Eteläranta 10
> FI-00130 Helsinki
> FINLAND
>
> Turku Office
> Kauppiaskatu 5 A
> FI-20100 Turku
> FINLAND
>

Re: Problem with sparql bind

Posted by Mikael Pesonen <mi...@lingsoft.fi>.
Okay so separate graph statements make the scopes too separate even if 
the graph is the same.

Thanks Martynas!

On 21/02/2020 11.16, Martynas Jusevičius wrote:
> ?s2 is undefined in the second GRAPH.
>
> On Fri, Feb 21, 2020 at 10:12 AM Mikael Pesonen
> <mi...@lingsoft.fi> wrote:
>> Hi,
>>
>> I've got this query that first selects some resources (into ?s2), then
>> gets all the resource triplets. BIND clause below is more complicated
>> and i need to have the BIND there, but problem occurs with this
>> simplified version too. So I'm expecting only the triplets for 5
>> resources ?s2 but below query is returning all the triplets in graph
>> https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0.
>> I must have error somewhere but could not find any help googling. Any
>> ideas? It has something to do with bind inside the graph.
>>
>> CONSTRUCT { ?s ?p ?o }
>> WHERE
>> {
>>           {
>>                   SELECT DISTINCT ?s2 WHERE
>>                   {
>>                           GRAPH
>> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>>                           {
>>                                   ?s2
>> <http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
>>                           }
>>                   }
>>                   OFFSET 0 LIMIT 5
>>           }
>>
>>           GRAPH
>> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>>           {
>>               BIND (?s2 as ?s) ?s ?p ?o
>>           }
>> }
>>
>>
>>
>> Moving bind outside graph works as intended:
>>
>> CONSTRUCT { ?s ?p ?o }
>> WHERE
>> {
>>           {
>>                   SELECT DISTINCT ?s2 WHERE
>>                   {
>>                           GRAPH
>> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>>                           {
>>                                   ?s2
>> <http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
>>                           }
>>                   }
>>                   OFFSET 0 LIMIT 5
>>           }
>> BIND (?s2 as ?s)
>>           GRAPH
>> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>>           {
>>                ?s ?p ?o
>>           }
>> }
>>
>> Thanks,
>> Mikael
>>

-- 
Lingsoft - 30 years of Leading Language Management

www.lingsoft.fi

Speech Applications - Language Management - Translation - Reader's and Writer's Tools - Text Tools - E-books and M-books

Mikael Pesonen
System Engineer

e-mail: mikael.pesonen@lingsoft.fi
Tel. +358 2 279 3300

Time zone: GMT+2

Helsinki Office
Eteläranta 10
FI-00130 Helsinki
FINLAND

Turku Office
Kauppiaskatu 5 A
FI-20100 Turku
FINLAND


Re: Problem with sparql bind

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
?s2 is undefined in the second GRAPH.

On Fri, Feb 21, 2020 at 10:12 AM Mikael Pesonen
<mi...@lingsoft.fi> wrote:
>
> Hi,
>
> I've got this query that first selects some resources (into ?s2), then
> gets all the resource triplets. BIND clause below is more complicated
> and i need to have the BIND there, but problem occurs with this
> simplified version too. So I'm expecting only the triplets for 5
> resources ?s2 but below query is returning all the triplets in graph
> https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0.
> I must have error somewhere but could not find any help googling. Any
> ideas? It has something to do with bind inside the graph.
>
> CONSTRUCT { ?s ?p ?o }
> WHERE
> {
>          {
>                  SELECT DISTINCT ?s2 WHERE
>                  {
>                          GRAPH
> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>                          {
>                                  ?s2
> <http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
>                          }
>                  }
>                  OFFSET 0 LIMIT 5
>          }
>
>          GRAPH
> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>          {
>              BIND (?s2 as ?s) ?s ?p ?o
>          }
> }
>
>
>
> Moving bind outside graph works as intended:
>
> CONSTRUCT { ?s ?p ?o }
> WHERE
> {
>          {
>                  SELECT DISTINCT ?s2 WHERE
>                  {
>                          GRAPH
> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>                          {
>                                  ?s2
> <http://www.w3.org/2006/vcard/ns#fn> "Some Body" .
>                          }
>                  }
>                  OFFSET 0 LIMIT 5
>          }
> BIND (?s2 as ?s)
>          GRAPH
> <https://resource.lingsoft.fi/graph/7641fe5e-f4af-4863-a1fa-484c77fa6df0>
>          {
>               ?s ?p ?o
>          }
> }
>
> Thanks,
> Mikael
>