1

I am currently working with the Microsoft Academic Knowledge Graph (MAKG) dataset, specifically using the RDF schema provided at https://makg.org/wp-content/uploads/2021/03/mag-rdf-schema-2021-03-2.png. I am querying the dataset using SPARQL through the MAKG SPARQL endpoint at https://makg.org/sparql-endpoint/.

My goal is to obtain a list of all fields of study along with their child records. The dataset indicates that there are 740,460 fields of study, but when I query the data, I only get the top-level fields without any child records.

SELECT DISTINCT ?FieldOfStudy
WHERE {
  [] a ?FieldOfStudy
}
LIMIT 100

Could you please guide me on how to construct a SPARQL query to retrieve the child records for each field of study?

Thank you in advance for your help!

Bobby
  • 13
  • 3
  • the shown query returns all types in the dataset, but **not** the fields of study. Gettings all fields of study would be `SELECT ?s WHERE { ?s a }` - but I'm not sufre what exactly you're aksing for – UninformedUser Jun 21 '23 at 11:30

1 Answers1

0

The triple pattern [] a ?FieldOfStudy finds triples

  • with any subject,
  • with the property rdf:type, and
  • with any object, because you didn’t bind that variable to something.

If you want to only find triples with the class https://makg.org/class/FieldOfStudy as object, you could specify this IRI directly. Note that the actual study fields would be the subjects in the triples, so it makes sense to use your variable ?FieldOfStudy in the subject position.

PREFIX magc: <https://makg.org/class/>

SELECT DISTINCT ?FieldOfStudy
WHERE {
  ?FieldOfStudy a magc:FieldOfStudy . 
}
LIMIT 10

You can count the results to verify that it finds 740460:

PREFIX magc: <https://makg.org/class/>

SELECT (COUNT(DISTINCT ?FieldOfStudy) AS ?count)
WHERE {
  ?FieldOfStudy a magc:FieldOfStudy . 
}