How to write SPARQL query for JSON data?

Hi Team,

I am unable to get the value of 'time' using SPARQL . Please find the details below and please do share the reference document which can help me to guide more on writing SPARQL query to JSON data.

SPARQL query -

SELECT *
WHERE {
?time a :time.
}

image

image
My output -

Thanks

Hi Raja,

Thanks for your question. You are not getting any results in your query because the graph pattern ?time a :time does not match any triples currently in the database. You can see exactly which triples are contained in the database after the virtual import by exporting the database as seen here in the documentation: Importing JSON and CSV Files | Stardog Documentation Latest

If you execute the following query, you should get 1 result, assuming you have only imported the sample JSON file with the example mapping file in the documentation.

PREFIX : <http://example.com/>

SELECT *
WHERE {
    ?block :time ?time
} 

Please also take note of providing the default namespace in the query (e.g. PREFIX : <http://example.com/>) If you do not want to provide the default namespace at query time, you can define a new default namespace at the database level. Please see the documentation for managing namespaces here: Managing Databases | Stardog Documentation Latest.

Even though the default prefix in the SMS2 mapping defined a default namespace of http://example.com/ , it does not get persisted at the database level just from the import - you would need to update it at the database level.

Hope that helps.

Cheers,
Noah

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.