Page MenuHomePhabricator

(MS 4) connect query conditions via OR
Closed, ResolvedPublic13 Estimated Story Points

Description

As an editor I want to connect the query conditions via OR to fetch the results if any one of the conditions in my query is true.

Problem:
The visual queries currently connect every condition with AND. There is no option to query for conditions connected with OR instead.

Example:

  • Query for instance of songs and genre with 'jazz' or 'rock'

Screenshots/mockups:
creating OR conditions
removing OR conditions
Going from OR to AND

BDD
GIVEN a visual query with two or more query conditions
THEN editor can choose either 'OR' / 'AND' concatenation
AND then results are displayed based on the chosen condition.

Acceptance criteria:

  • Have option to choose AND / OR conditions to query
  • Run the visual query with OR statements
  • Default setting of toggle button group is always "and"
  • Connector is always centered behind the active button

Notes:

  • no change in spacing for layout 4

Sparql Example:

?song wdt:P31 wd:song.
{ ?song wdt:genre wd:rock. } UNION
{ ?song wdt:genre wd:jazz. }

Complete SPARQL Based on current Generator:

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/ps:P136) wd:Q8341. } UNION
     { ?item (p:P136/ps:P136) wd:Q11399. }
     }
    LIMIT 100
  }
}

Event Timeline

amy_rc created this task.Jan 22 2021, 11:42 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 22 2021, 11:42 AM
amy_rc updated the task description. (Show Details)Jan 22 2021, 3:07 PM
amy_rc moved this task from Incoming to Backlog on the Wikidata Query Builder board.
Charlie_WMDE updated the task description. (Show Details)Jan 25 2021, 6:30 PM
Lydia_Pintscher renamed this task from (MS 4) Make OR statements to (MS 4) connect query conditions via OR.Jan 25 2021, 6:58 PM
Lydia_Pintscher updated the task description. (Show Details)
Lydia_Pintscher triaged this task as High priority.Jan 26 2021, 9:28 AM
Lydia_Pintscher set the point value for this task to 13.Jan 26 2021, 10:24 AM

Estimate without connecting line - that will get its own ticket.

Charlie_WMDE updated the task description. (Show Details)Jan 26 2021, 3:15 PM
guergana.tzatchkova updated the task description. (Show Details)
amy_rc added a comment.EditedFri, Feb 5, 1:27 PM

When I try the below query without subclasses, references, without references with the AND, OR conditions, I observe various kind of results. I think it is due to filter references. So, I have also created a bug report for this.

  1. Q569815 is an instance of song but genre= house music
  2. Q548923 is an instance of song, and genre= psychedelic pop and is subclass of pop.

SCREENSHOT

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
  }
}

But is it wrong?
On the regardless mode for references I get:

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item (p:P31/ps:P31/(wdt:P279*)) wd:Q7366.
      { ?item (p:P136/ps:P136/(wdt:P279*)) wd:Q8341. }
      UNION
      { ?item (p:P136/ps:P136/(wdt:P279*)) wd:Q11399. }
    }
    LIMIT 100
  }
}

Which is correct.

amy_rc added a comment.Tue, Feb 9, 9:29 AM

Did you try the same without the subclasses?

Yeah:

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/ps:P136) wd:Q8341. }
      UNION
      { ?item (p:P136/ps:P136) wd:Q11399. }
    }
    LIMIT 100
  }
}

I think we should call this done and handle the bug in T274101: Filter by References not working

This comment was removed by amy_rc.
amy_rc closed this task as Resolved.Wed, Feb 10, 10:37 AM
amy_rc claimed this task.

✨ \o/