Page MenuHomePhabricator

Filter by References not working
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:
Create a visual query with the below conditions:

  1. with instance matching song with and without references, uncheck 'Include values from subclasses of this value'
  2. choose AND condition, with genre matching jazz filter by only with references, uncheck 'Include values from subclasses of this value'
  3. choose OR condition, with genre matching rock music filter by only with references, uncheck 'Include values from subclasses of this value'
  4. Run the query


Actual Results:
Results showing different genre

Expected Results: The results should be filtered by jazz and rock music excluding others.

SPARQL:

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item (p:P31/ps:P31) wd:Q7366.
      { ?item p:P136 ?statement0. }
      UNION
      { ?statement0 (ps:P136) wd:Q8341. }
      UNION
      { FILTER(EXISTS { ?statement0 prov:wasDerivedFrom ?reference. }) }
      UNION
      { ?item p:P136 ?statement1. }
      UNION
      { ?statement1 (ps:P136) wd:Q11399. }
      UNION
      { FILTER(EXISTS { ?statement1 prov:wasDerivedFrom ?reference. }) }
    }
    LIMIT 10
  }
}

Event Timeline

amy_rc renamed this task from References not working to Filter by References not working.Feb 8 2021, 9:51 AM
amy_rc updated the task description. (Show Details)
amy_rc updated the task description. (Show Details)
Michael added a subscriber: Michael.

Yes, that is indeed incorrect. What we want is sparql like that:

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item (p:P31/ps:P31) wd:Q7366.
      { ?item p:P136 ?statement0.
       ?statement0 (ps:P136) wd:Q8341.
       FILTER(EXISTS { ?statement0 prov:wasDerivedFrom ?reference. }) }
      UNION
      { ?item p:P136 ?statement1.
        ?statement1 (ps:P136) wd:Q11399. 
        FILTER(EXISTS { ?statement1 prov:wasDerivedFrom ?reference. }) }
    }
    LIMIT 10
  }
}

See https://w.wiki/yNK

Tested and works fine 💃