Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: SPARQL result format and protocol #360

Closed
LorenzBuehmann opened this issue Nov 12, 2020 · 6 comments · Fixed by #362
Closed

Question: SPARQL result format and protocol #360

LorenzBuehmann opened this issue Nov 12, 2020 · 6 comments · Fixed by #362

Comments

@LorenzBuehmann
Copy link

LorenzBuehmann commented Nov 12, 2020

Hi QLever team,

first of all, very interesting and impressive work, congratulations!

I'm playing around with it right now, but it looks like QLever doesn't support a proper SPARQL resultset format like SPARQL JSON? Is this correct? Any plans to add it in the future?
I'm asking because the current result format makes it impossible to use some of the more popular SPARQL APIs like Apache Jena, rdf4j, rdflib(sparqlwrapper) etc. without writing an own SPARQL result parser.

Thanks in advance and well done, nice work!

PS: Looks like your public demo doesn't work, at least I'm getting a backend connection error notification when choosing a dataset.

@hannahbast
Copy link
Member

@LorenzBuehmann Thank you for your comment, we have finally addressed this with #362 . The format is supported via header "Accept: application/sparql-results+json" (the standard way) as well as via URL parameter action=sparql_json_export (useful in contexts, where only a URL can be specified).

Currently, the default format (when no Accept header or action argument is specified) is still QLever's own JSON format (which is more compact and contains meta information about the query processing). Let us know if you think that it's important that application/sparql-results+json is the default format.

@LorenzBuehmann
Copy link
Author

LorenzBuehmann commented May 30, 2022

Hi, I guess we have to reopen this issue. You made a small mistake in the SPARQL JSON format, you're returning

{"type":"iri","value":"https://www.openstreetmap.org/node/1758067925"}

but in fact the format specifies only the type uri and not iri because of legacy reasons.

See https://www.w3.org/TR/sparql11-results-json/#select-encode-terms

@joka921
Copy link
Member

joka921 commented May 30, 2022

You have a very good timing. We have discovered the same bug among others (Variables are "someVariable" and not "?someVariable" and blank nodes were returned as literals) at the end of last week. I have drafted a quick fix this morning which we will hopefully merge soon (#677)

@joka921 joka921 reopened this May 30, 2022
@hannahbast
Copy link
Member

@joka921 This is resolved, is it not?

@namedgraph
Copy link

namedgraph commented Dec 5, 2022

I can confirm I get JSON results back:

curl -H "Accept: application/sparql-results+json" 'https://qlever.cs.uni-freiburg.de/api/wikidata?query=PREFIX+wd%3A+%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX+wt%3A+%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0ASELECT+DISTINCT+%3Fname+%3Fpopulation+WHERE+%7B%0A++%3Fcity+wdt%3AP31%2Fwdt%3AP279*+wd%3AQ515+.%0A++%3Fcity+wdt%3AP17+wd%3AQ183+.%0A++%3Fcity+wdt%3AP1082+%3Fpopulation+.%0A++%3Fcity+rdfs%3Alabel+%3Fname+.%0A++FILTER+(LANG(%3Fname)+%3D+%22de%22)%0A%7D%0AORDER+BY+DESC(%3Fpopulation)&send=100'

But not XML results however:

curl -H "Accept: application/sparql-results+xml" 'https://qlever.cs.uni-freiburg.de/api/wikidata?query=PREFIX+wd%3A+%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX+wdt%3A+%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0ASELECT+DISTINCT+%3Fname+%3Fpopulation+WHERE+%7B%0A++%3Fcity+wdt%3AP31%2Fwdt%3AP279*+wd%3AQ515+.%0A++%3Fcity+wdt%3AP17+wd%3AQ183+.%0A++%3Fcity+wdt%3AP1082+%3Fpopulation+.%0A++%3Fcity+rdfs%3Alabel+%3Fname+.%0A++FILTER+(LANG(%3Fname)+%3D+%22de%22)%0A%7D%0AORDER+BY+DESC(%3Fpopulation)&send=100'

This returns 400 Bad Request. Is support for XML results planned as well?

@joka921
Copy link
Member

joka921 commented May 10, 2024

In the meantime we export results as TSV as well as as XML.

@joka921 joka921 closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants