1

I have a query to get some similar instances for a specific instance, which is owbes:Dies_Irae instance. This is the query:

CONSTRUCT { ?recommendable0 ?predicate0 ?similarity0 } WHERE {
  ?recommendable0 ?predicate0 ?object0.
  owbes:Dies_Irae ?predicate0 ?object0.
  ?predicate0 owbes:hasSimilarityValue ?similarity0.
  ?recommendable0 rdf:type ?someType.
  ?someType rdfs:subClassOf owbes:Recommendable.
}

It works fine, I get in the results what I'm supposed to. However, I also get the same instance owbes:Dies_Irae. Is there a way to exclude it from the result?

Well, I'm sure there is. I tried to search, I found that there is a filter, I tried to use it, but no succeed. This is the filter that I apply FILTER (?recmmendable0 != owbes:Dies_Irae)

I also tried to check if both of them have the same rdf:about but it didn't work.

Here you go the result:

<http://www.welovethesemanticweb.com/recommendation-systems#Requiem:_Sequentia>
        recommendation-systems:hasArtist
                "0.4"^^xsd:double .

recommendation-systems:Le_nozze_di_Figaro
        recommendation-systems:hasArtist
                "0.4"^^xsd:double .

recommendation-systems:Dies_Irae
        recommendation-systems:hasArtist
                "0.4"^^xsd:double .

as you see, the last instance is the one that I'd like to exclude

Ania David
  • 1,168
  • 1
  • 15
  • 36
  • **"I also tried to check if both of them have the same rdf:about but it didn't work."** I think you may misunderstand what **rdf:about** in the RDF/XML serialization means. It's not a property. It's just one of the several possible ways that the XML serialization uses to identify the IRI being described. You may find http://stackoverflow.com/questions/7118326/differences-between-rdfresource-rdfabout-and-rdfid helpful, as well as http://stackoverflow.com/questions/34446778/sparql-query-using-rdfid-returns-no-results. – Joshua Taylor Feb 05 '16 at 15:51

1 Answers1

2
FILTER (?recmmendable0 != owbes:Dies_Irae)

You didn't spell recommendable0 correctly in your filter. Since the variable isn't used anywhere else, it never has a value, so the filter doesn't have anything to compare.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thank you, I'm always a miss in English. – Ania David Feb 05 '16 at 16:26
  • Please can I ask you how can I query the graph that I get from the constract query? I need to make aggregation on the result of the constract graph – Ania David Feb 05 '16 at 16:42
  • This is a different question, so please open a new one. As a short hint: you would have to use sub SELECT + BIND inside the where part of the CONSTRUCT query. You can't nest CONSTRUCT queries. – UninformedUser Feb 05 '16 at 16:44
  • 1
    You can't query the **construct**ed graph directly. You'd have to save it and then run a separate query. However, you *can* do the aggregation in a subquery, and the construct from the results of that. As @AKSW says, that's really a separate question, but don't post it just yet; I think there's already a question like that on here... – Joshua Taylor Feb 05 '16 at 16:45
  • @AniaDavid Yes, have a look at [SPARQL functions in CONSTRUCT/WHERE](http://stackoverflow.com/q/28427219/1281433). – Joshua Taylor Feb 05 '16 at 16:47
  • @JoshuaTaylor please can you help me again? https://stackoverflow.com/questions/35273681/how-to-create-aggregation-on-a-graph-from-construct I value that a lot – Ania David Feb 08 '16 at 16:40
  • Would it be possible to do this with MINUS instead of FILTER? – Julian Dm Jun 28 '20 at 15:15