I am using clj-plaza
(0.0.5-SNAPSHOT) to query a Sesame/Jena Model. The function model-query
does not appear to execute the query. It returns the internal representation of a clj-plaza
query instead.
(init-jena-framework)
(def *m* (build-model))
(with-model *m*
(model-add-triples
(model-to-triples
(document-to-model "http://www.rdfdata.org/dat/rdfdata.rdf"
:rdf))))
(def all-subjects-query
(defquery
(query-set-vars [:?subject])
(query-set-pattern (make-pattern [[:?subject ?p ?o]]))
(query-set-type :select))
;; As expected
(model-query-triples *m* all-subjects-query)
=> clojure.lang.LazySeq@2e1e8502
;; Does not execute query (?)
(model-query *m* all-subjects-query)
=> {:kind :select, :pattern [[:?object :?p :?o]], :vars [:?object]}
The official tutorial claims model-query
returns a list of bindings from the query:
({:?object "http://randomurl.com/asdf"}
{:?object "http://asdf.com/qwer"})
This is a bug.
Here is a fix. Until it is merged back and updated on clojars, feel free to use my fork.
A workaround would be to use
(query model query)
(instead ofmodel-query
)after importing the corresponding Jena or Sesame implementation.For Sesame: