Extremely basic question about properties with multiple values
I feel like I'm missing something obvious here, but I do not understand how to select pages with #ask where a property with multiple values shouldn't have a certain value.
I'll just use the demo pages here for an example:
{{#ask: [[Located in::Europe]] [[Located in::!Europe]] }}
It seems to me like this query should select nothing, but it it renders England, due to that page's "Located in" property having multiple values, both Europe and United Kingdom. (According to the definition of the ! operator, this is technically the expected behavior, i.e. England is a page that does have a value other than Europe for it's "Located in" property.)
So the use case I have is a property where the values do not even have a hierarchical relationship. For example, let's assume we have pages with a "Has colors" property that can have more than one value of red, green, blue, etc. How would I go about selecting pages that are not red?
Just exclude red:
{{#ask: [[Has colors::!red]] }}
This query will list all pages holding the "Has colors" property but without red as the annotated value. See also this example.
Ok, so it turns out that things are not so easy as they appear. Currently it depends on the data backend used which results you will be getting. The example page used uses the supplementary "SMWElasticStore" backend which will be available with SMW 3.0. Here you are getting the result as shown, whereas if you are using the "SMWSQLStore3" backend it indeed turns out that it is not possible this way. So you have to apply some tricks, e.g. adding a (hidden) category called e.g. "Has colors red" or better model a different data structure with using sub-properties like "Has colors red" both allowing for direct selection for querying. I must note that you do not necessarily have do set up this extra property as a sub-property.