AllegroGraph check existing triple

2019-07-12 15:28发布

问题:

I am using AllegroGraph 4. I have a triple store, and I am trying to add new triples only if they don't already exist.

Here is my Prolog query:

(select (?news) (alfas ?news) (a-- ?news !tst:has-annotation !tst:Test)))

where alfas checks for a condition(it works fine) and a-- is defined like this:

(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lisp (not (triple-exists-p ?s ?p ?o)))
(lisp (add-triple ?s ?p ?o)))

I have also tried defining it like this:

(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lisp (not (get-triple :s ?s :p ?p :o ?o)))
(lisp (add-triple ?s ?p ?o)))

But the triple is added anyway, no matter if it already exists or not. Why?