How to make mongodb work with virtual graphs?

this is my users collection.

image

i'm trying to follow tuts from here

https://www.stardog.com/docs/#_mongodb_virtual_graph_considerations

PREFIX : <http://kim.jong.un/onto#>

MAPPING <urn:users>
FROM JSON {
    "users": {
        "_id": "?id",
        "username": "?username"
    }
}
TO {
    ?user a :User;
        :username ?username .
}
WHERE {
    BIND (template("http://kim.jong.un/onto#{id}") AS ?user)
}

but no result were found.

You probably need to declare the : prefix in your SPARQL query at the top:
prefix : <http://kim.jong.un/onto#>

weird i've this in Namespaces

after adding this still doesn't return anything.

Can you click "Show Plan" and then "Text" and paste it here? You can use three backticks to quote text blocks.

prefix : <http://kim.jong.un/onto#>

Distinct [#1]
`─ Projection(?user, ?username) [#1]
   `─ Empty [#1]

You've registered the virtual graph named "users", right? What happens if you put ?s ?p ?o in the graph <...> { block? Can you show the plan again?

this is my ttl file and its almost empty

@prefix : <http://kim.jong.un/onto#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://kim.jong.un/onto> .

<http://kim.jong.un/onto> rdf:type owl:Ontology .

#################################################################
#    Annotation properties
#################################################################

###  http://kim.jong.un/onto#标签名称
:标签名称 rdf:type owl:AnnotationProperty .


#################################################################
#    Data properties
#################################################################

###  http://kim.jong.un/onto#_id
:_id rdf:type owl:DatatypeProperty .


###  http://kim.jong.un/onto#username
:username rdf:type owl:DatatypeProperty .


#################################################################
#    Classes
#################################################################

###  http://kim.jong.un/onto#User
:User rdf:type owl:Class .


###  Generated by the OWL API (version 4.2.8.20170104-2310) https://github.com/owlcs/owlapi

Did you create the virtual graph? Can you show that tab?

Can you try it with reasoning disabled?

oh sorry i thought i put this in first comment

and yes i've tried toggle reasoning

PREFIX : <http://kim.jong.un/onto#>

MAPPING <urn:users>
FROM JSON {
    "users": {
        "_id": "?id",
        "username": "?username"
    }
}
TO {
    ?user a :User;
        :username ?username .
}
WHERE {
    BIND (template("http://kim.jong.un/onto#{id}") AS ?user)
}

The virtual graph name showing in the screenshot is dezhi. In your SPARQL query, you should reference the graph virtual://dezhi.

1 Like

awesome

i thought virtual:// is from "keyword" after "MAPPING"

No, that's a way to refer to the mapping in the case of multiple mappings. I'll get the documentation updated to clarify this. Glad you got it working.

1 Like

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