-1

I am trying to test an existing relation (objectpropertie) for a given resource.

Let's take an exemple :

I would like to know if a subject ?a has a predicate with one of values in a sparql variable ?b. So ?a can contains an uuid (or what you want but it is my case) and ?b contains a list of resources (:hot, :cold, :good). If my variable ?a has at least one link with values of my variable ?b, sparql doesn't have to return it.

The problem is sparql returns my variable ?a 3 times. If ?b contains 10 resources, it will return ?a 10 times. Is there any possibility to say in SPARQL "IN ONE OF THOSE" or making a sub query with ASK statement.

SELECT * WHERE { 
    ?donnee a capt:VALEUR .             
    ?donnee tag:Est ?tag .
    ?modele tag:Modelisé_Avec ?tag .
    ?tag tag:A_Pour_Père/tag:Qualifié_Par ?qual .
    ?qualif tag:A_Pour_Père ?qual .
    FILTER (?modele = tag:Modèle_qualification_température_intérieure) .
    FILTER NOT EXISTS {?donnee tag:Qualifié_Par ?qualif .}
}

The problem is about ?qualif variable. Thanks.

EDIT : As asked, here you can see some details.

  • My goal is getting values that are not "linked" with ?qual which is a group of ?qualif => :Chaud, :Doux, :Frais, :Froid resources.
  • In natural language (with my poor english ;) ) : get me all values that are not tagged with one of the ?qualif contains in ?qual variable. If data have already been tagged, don't return it.
  • The problem is I have 2307 values in my triplestore, and the result is 9227. Why ? I think it's because my request doing that :
    Value1 -----> :Chaud
    then
    Value1 -----> :Doux
    then
    Value1 -----> :Frais
    then
    Value1 -----> :Froid
    
    etc... with all values

Actual Result

As you can see here, there are 9227(-1) results but i have got 2307 values => 2307x4.

Is it clearer for you ? Thanks for your help.

TallTed
  • 9,069
  • 2
  • 22
  • 37
A.Dumas
  • 63
  • 1
  • 5
  • Please show your current query. – UninformedUser Sep 16 '19 at 13:20
  • what is the problem with the `?qualif` var? I mean, you do `select * `, i.e. select all variables. The query just returns all possible bindings now. If you don't want to get one of the variables, don't select it. Note, if no value would exists, the whole result would be empty. – UninformedUser Sep 16 '19 at 13:26
  • ?qualif var contains a list of "object". So for each ?donnee it will test in FILTER NOT EXISTS ?donnee tag:Qualifié_Par ?qualif where ?qualif can be ":cold, :hot, :good" and more in some cases. I suppose it's my problem about the number of result. To illustrate : i'have got 2000 values in my triplestore and the result of this request return 6000 rows. – A.Dumas Sep 16 '19 at 13:27
  • 2
    sorry, it's really hard for me to understand it. Can you maybe show some sample data + the current result + the expected result. It's really hard to debug other queries without having access to the triple store with the loaded data. And I do not speak French, thus, I don't understand the domain. – UninformedUser Sep 16 '19 at 13:41
  • Can I send you a part of my ontology in private message ? – A.Dumas Sep 17 '19 at 07:06
  • 1
    You do not need the variable `?qualif` in the resultset, right? So, don't do `select *` but enumerate the variables you want to get and use `select distinct ?var1 ?var2 ...` – UninformedUser Sep 17 '19 at 14:04

1 Answers1

0

thanks for your answer.

"Select * " statement was to simplify the request. Yet I tried your solution and it doesn't work. If I add "Distinct", yeah it works. Thanks for that. I find another solution this morning without "DISTINCT" :

SELECT ?donnee WHERE{ 
            ?modele tag:Modelisé_Avec ?tag .
            ?donnee tag:Est ?tag .
            ?tag tag:A_Pour_Père/tag:Qualifié_Par ?qual .
            FILTER (?tag = tag:Température_intérieure)  .   
            FILTER NOT EXISTS { ?donnee tag:Qualifié_Par ?qualif .
                                ?qualif tag:A_Pour_Père ?qual . }}

I put "?qualif tag:A_Pour_Père ?qual" in "FILTER NOT EXISTS" instead of "SELECT" and it works without "DISTINCT" and "SELECT *" Thanks for your time.

A.Dumas
  • 63
  • 1
  • 5