I'm trying to query a FOAF like dataset. I want to query the dataset for 10 people (and only people with friends) and get back their names and their friends uris.

Based on this solution: http://answers.semanticweb.com/questions/21072/limiting-individuals-not-statements I tried the foloowing:

select ?person ?name ?knows
where {
    ?person a foaf:person .
    ?person foaf:name ?name .
    ?person foaf:knows ?knows .
       select ?person where {
          ?person a foaf:person
      } LIMIT 10

This query still limits by statements and not the resource, so if the first person returned from this query has 10 friends, I'm only going to get the statements for that first person.

What am I doing wrong?

asked 18 Feb '13, 14:18

iuviene's gravatar image

accept rate: 0%

Well that query should work as stated, one possible issue is that it is entirely possible that the inner query is returning the same ?person 10 times because of how your data is organised. Try adding the DISTINCT modifier to your inner query and see if that makes a difference:

SELECT ?person ?name ?knows
    ?person a foaf:person .
    ?person foaf:name ?name .
    ?person foaf:knows ?knows .
       SELECT DISTINCT ?person WHERE {
          ?person a foaf:person
      } LIMIT 10

If this still doesn't give you the result you want this may be a bug in the SPARQL engine you are using, what are you using to make your query and how is your data stored?

permanent link

answered 18 Feb '13, 15:32

Rob%20Vesse's gravatar image

Rob Vesse ♦
accept rate: 29%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 18 Feb '13, 14:18

question was seen: 474 times

last updated: 18 Feb '13, 15:32