Page MenuHomePhabricator

Request: sort by property values without restricting query results to require this property value
Closed, DeclinedPublic

Description

See the example page.

Apparently this is well known bug, but I couldn't find it from this bugzilla. I was able to dig into the queries:

Default sort:
SELECT DISTINCT t3.smw_id AS id,t3.smw_title AS t,t3.smw_namespace AS ns,t3.smw_iw AS iw,t3.smw_subobject AS so,t3.smw_sortkey AS sortkey
FROM smw_ids AS t3 INNER JOIN smw_rels2 AS t0 ON t3.smw_id=t0.s_id
WHERE (t0.p_id='821' AND t0.o_id='6343')
ORDER BY t3.smw_sortkey ASC LIMIT 21;

Other sort:
SELECT DISTINCT t3.smw_id AS id,t3.smw_title AS t,t3.smw_namespace AS ns,t3.smw_iw AS iw,t3.smw_subobject AS so,t3.smw_sortkey AS sortkey
FROM smw_ids AS t3 INNER JOIN smw_rels2 AS t0 ON t3.smw_id=t0.s_id
INNER JOIN smw_atts2 AS t5 ON t3.smw_id=t5.s_id
WHERE (t0.p_id='821' AND t0.o_id='6343') AND (t5.p_id='803')
ORDER BY t5.value_xsd ASC LIMIT 21;

By changing INNER JOIN to OUTER JOIN and removing the new AND condition I get some results, but my SQL skills are not enough to determine whether it would also return bogus results in some cases.

And even if that was the correct query, I'm not able to change the SMW query generator to make such query.


Version: unspecified
Severity: enhancement
URL: http://tieteentermipankki.fi/wiki/Testisivu

Details

Reference
bz33705

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:59 PM
bzimport set Reference to bz33705.
bzimport added a subscriber: Unknown Object (MLST).

Actually, this is not a bug but the expected behaviour. SMW requires sort properties to be set. If anything else is documented in the manual, then this should be corrected.

It might be possible to change the SQL and SPARQL generation procedures to do this differently, but I think there is a risk of this leading to problems with various database tools, even if it is allowed according to the respective standards. And it might have an impact on performance. I leave this open as a feature request in case somebody wants to take this challenge in the future.

The use case is very clear: you have items you want to show in some order, not all of them might have the sorting field set.

Aklapper subscribed.

The Semantic MediaWiki developers requested in https://phabricator.wikimedia.org/T64114 to move their task tracking to https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues and to close remaining tasks in Wikimedia Phabricator. If you still face the problem reported in this task in a supported version of SMW, please feel free to transfer your report to https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues . We are sorry for the inconvenience.