Page MenuHomePhabricator

Random Sort for semantic queries
Closed, ResolvedPublic

Description

Author: steren.giannini

Description:
Random sort

I wrote a small patch for SMW. It allows to sort query results randomly.

Just write "|sort=random" in the {{#ask}} params.

It's compatible with other sorting, which means you can sort ascending by one property and then sort randomly by an other property.
example:
{{#ask: [[test::+]][[check::+]]

?? test? check
sort = test, check
order = asc, rand
limit = 3

}}

It uses the MySQL RAND() function [1], which may not be very efficient on a large number of row [2].
I hope this will be useful. Feel free to add this patch to the SMW development repository if you want.

[1] : http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_rand
[2] : http://forums.mysql.com/read.php?24,163940,163940

Steren


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz14978

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:12 PM
bzimport set Reference to bz14978.

Assigned to Markus. Added keyword "patch".