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

image.png (807×1 px, 90 KB)

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

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)

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

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

image.png (660×1 px, 61 KB)

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.

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

image.png (747×1 px, 76 KB)

This comment was removed by amy_rc.
amy_rc claimed this task.

✨ \o/