Page MenuHomePhabricator

wikibase:mwapi query with additional conditions fails to apply these conditions
Closed, ResolvedPublic

Description

For some objects, query with wikibase:mwapi request returns empty items.
It becomes a problem when there are no Wikidata item is linked to article.
But such thing can happen even when item is linked.
For example, here ?item for "Введенская церковь (Ольгово)" article shows as empty, while it is in fact linked (Q59641456):

SELECT ?item ?title WHERE {
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:endpoint "ru.wikipedia.org" .
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam mwapi:generator "search" .
    bd:serviceParam mwapi:gsrsearch "intitle:/Введенская церковь \\(О/" .
    bd:serviceParam mwapi:gsrlimit "max" .
    ?item wikibase:apiOutputItem mwapi:item .
    ?title wikibase:apiOutput mwapi:title
  }
}

Q59641456 was edited at 11 Dec, "Введенская церковь (Ольгово)" last edit at 7 Nov, so further waiting have no sense.
Problematic state can be removed by making an edit to wikidata item, so stable reproducibility is under the risk.

Event Timeline

Vort created this task.Dec 16 2018, 1:02 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptDec 16 2018, 1:02 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Could you describe what you mean by "shows as empty"? Do you mean this request does not return anything or that it returns some response, but some parts are empty? Which ones?

Vort added a comment.Dec 22 2018, 1:16 PM

Bug with Q59641456 (part two) is not reproducing anymore.
But empty values still can be seen with such request (part one):

SELECT ?item ?title WHERE {
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:endpoint "ru.wikipedia.org" .
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam mwapi:generator "search" .
    bd:serviceParam mwapi:gsrsearch "intitle:/Дом[-]музей [БК]о/" .
    bd:serviceParam mwapi:gsrlimit "max" .
    ?item wikibase:apiOutputItem mwapi:item .
    ?title wikibase:apiOutput mwapi:title
  }
}

They becomes a problem when I want to fetch sitelinks (result is query timeout or browser tab crash):

SELECT ?item ?lang WHERE {
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:endpoint "ru.wikipedia.org" .
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam mwapi:generator "search" .
    bd:serviceParam mwapi:gsrsearch "intitle:/Дом[-]музей [БК]о/" .
    bd:serviceParam mwapi:gsrlimit "max" .
    ?item wikibase:apiOutputItem mwapi:item .
  }
  ?sitelink schema:about ?item .
  ?sitelink schema:inLanguage ?lang
}

But I'm not sure if such behavior is wrong.

Smalyshev triaged this task as Normal priority.Jan 2 2019, 11:48 PM

The empty ?item behavior seems to be normal - e.g. https://ru.wikipedia.org/wiki/%D0%94%D0%BE%D0%BC-%D0%BC%D1%83%D0%B7%D0%B5%D0%B9_%D0%91%D0%BE%D1%80%D0%B8%D1%81%D0%B0_%D0%9F%D0%B0%D1%81%D1%82%D0%B5%D1%80%D0%BD%D0%B0%D0%BA%D0%B0 does not have a Wikidata entry. This may not be a good thing Wikipedia-wise (seems to be notable enough to have one) but API-wise the result is exactly what is expected.

However, the query timeout in the second one is not right - I think somehow it fails to perform a proper join between MWAPI result and the graph pattern.

Smalyshev renamed this task from wikibase:mwapi query returns empty objects to wikibase:mwapi query with additional conditions fails to apply these conditions.Jan 2 2019, 11:49 PM

May also be related to T197598.

Smalyshev closed this task as Resolved.Jun 4 2019, 7:06 AM
Smalyshev claimed this task.

The queries seem to work fine now.