Page MenuHomePhabricator

Advanced (boolean) #ask: functions
Closed, DeclinedPublic

Description

Author: naught101

Description:
Currently it appears that it's only possible to do boolean AND #ask commands. It would be very useful to be able to use boolean OR and NOT functions as well.

Examples:
{{#ask: [[Category:Cities]] [[Location::Europe]]}} is a boolean AND and will return all cities in europe.

However, this is limited, as it's not possible to find cities in two countries, for example those who speak German:
{{#ask: [[Category:Cities]] AND [[Location::Germany]] OR [[Location::Luxembourg]] OR [[Location::Austria]] OR [[Location::Switzerland]] }}

Or all cities in mainland europe:
{{#ask: [[Category:Cities]] AND NOT [[Location::United Kingdom]] OR [[Location::Ireland]] }}

These are pretty basic examples, but such functionality would make the #ask function much, much more useful in many situations.


Version: unspecified
Severity: enhancement

Details

Reference
bz13886

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:07 PM
bzimport set Reference to bz13886.
bzimport added a subscriber: Unknown Object (MLST).

Actually it is possible. It should be documented, I didn't need to search any source code to know how to do these.

For your two examples these should work:

{{#ask: [[Category:Cities]] [[Location::Germany||Luxembourg||Austria||Switzerland]] }}

and for the other:

{{#ask: [[Category:Cities]] [[Location::!United Kingdom||Ireland]] }}

Basically the two things you didn't catch in the user manual are:

After the :: in ask queries an operator is allowed. This may be >, <, !, and if the wiki has it enabled ~ is also allowed. The > and < are for inclusive greater and less than (They are actually the same as >= and <= rather than the exclusive forms), and ! is for things which are not part of a property. The ~ isn't enabled by default, but it is for LIKE queries, in the form where ? is one character and * is any number of characters.

And the other thing is that inside of a property you can separate multiple allowed values (an OR) with two pipes ||.

naught101 wrote:

great, thanks Dan.