Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create advanced queries with a series of AND/OR's with semantic mediawiki?

How would one create a query like this the following?

get a list of persons where the hair color is brown or black and eye color is blue or green.

The reason i'm asking this is because i'm unsure of how precedence is handled in these queries.

For example if i wrote:

#ask: [[Category:Person]] 
      [[Hair color::brown]] OR [[Hair color::black]] 
      [[Eye color::blue]] OR [[Eye color::green]]

Would smw group the logic as: ( ( hair = brown or black ) and ( eyes = blue or green ) )

or

would the logic be grouped as: ( hair = brown or ( hair=black and eyes=blue ) or eyes = green )

From my initial tests it seems that the latter seems to be the case which seems to make it impossible to create the query i'm after.

Is this feature lacking in smw?

like image 955
netbrain Avatar asked Oct 14 '13 07:10

netbrain


1 Answers

Think i just found the answer: the query should be written as such:

  #ask: [[Category:Person]] 
  [[Hair color::brown||black]]
  [[Eye color::blue||green]]

This will give me the correct presecende so logic would get grouped as: ( ( hair = brown or black ) and ( eyes = blue or green ) )

like image 174
netbrain Avatar answered Sep 30 '22 09:09

netbrain