Help talk:Selecting pages/Archive

Sense of documentation
By using other categories or properties than above, we can already ask for pages which have certain annotations.

I don't quite get how this sentence is relevant to the text that is either preceding or following it?! --Reinout van Schouwen 10:11, 11 August 2008 (UTC)

Capitalization
It appears that if the predicate is  then the query fails. If the predicate is  then the query succeeds. I do wish that SMW could fix that, auto-capitalizing the name of the namespace.

Searching for not set properties
I would like to search for properties, which are not set. How do I do that ? --Toka 22:54, 1 February 2010 (UTC)


 * Hi Toka, just go to "Special:SpecialPages" and the select "Special:WantedProperties" in the section "Maintenance reports". Cheers --kgh 23:34, 23 March 2010 (UTC)

I think there is a difference in "Special:WantedProperties" and what is being asked. I too would like to be able to see all pages that have not used a particular property. For example, If there is a property for phone number and some people have set up pages with a phone number and some have not, I would like to query to find those that have pages with no phone number property set. Thanks for any feedback.


 * I also want to select Pages without a particular Property. Any news on that issue?


 * +1 (asking the same thing).Ankostis 13:30, 10 December 2010 (CET)
 * same here Svdubl 17:00, 27 January 2010 (CET)


 * I should note that there's a workaround that's not ideal, but it works: if you're using a template to store the SMW data, you can have the template store some property like " No phone number::true " if there's no value for that template field, using the #if function - and then query on that. Yaron Koren 15:48, 27 January 2011 (CET)


 * That would indeed be very useful. I am using an "Action Item" triplet (Category/Template/Form), and would like to display all the items that have not set the "Completion Date" property. In the meantime, could someone give an example of how one would use the #if as mentioned by Yaron ?
 * Ankostis 15:11, 26 May 2011 (CEST)


 * You can also define an array (using the Array Extension) to the result of an #ask query for all pages (or at least the ones in the main namespace, or whatever), then another one with an #ask for all pages with that property set, then #arraydiff them to create the array of pages without the property set. Not ideal, but I think it's cleaner than adding another property, and works even if you don't set that particular property with a template.  It sounds like a pain in the butt, but all you have to do is make a template with something like




 * and call it like and then #arrayprint the result (it'll be called whatever you specified to be name of array) however you like.

--EvgeniyDankovcev 04:26, 16 December 2011 (CET) I found a different workaround that worked in my case. say, we ask for animals inside a category animal and output ones that have age not set. . inside a template Template:Animals without age:

NB it's not an optimal performance query since it actually selects all animals instead of selecting only ones that don't have age NB2 for this to work you must have parser function extension turned on

Searching for pages NOT in Categories
How do you select pages with an non-set category in a query? E.g. if we had a 'NOT' operator, it might be to look for pages without the 'Conclusion' category set. I have tried Conclusion::, Conclusion::!+, Conclusion::! and Conclusion::'' with no luck. Thanks, Mark J Dayel 21:35, 25 March 2010 (UTC) Alex Mashin{{sup|talk}} 19:37, 23 November 2013 (CET)
 * Me also needing this feature. Ankostis 13:28, 10 December 2010 (CET)
 * Yah. Would be extremely useful operator. - Lbillett 2011-02-10
 * Yes! Such a feature would be very helpful indeed! --Gollum 13:16, 21 July 2011 (CEST)
 * I absolutely support this. There are a sh!loads of usecases, fx {{#ask: --Eric 21:54, 27 September 2011 (CEST)
 * +1. This would be a very helpful feature! Stefahn (talk) 13:45, 23 November 2013 (CET)
 * Would be very helpful. Also page names and namespaces should allow negation (with a minus perhaps).

distance calculation
The distance calculation, described at LIKE comparator seems not to work since SMW 1.5.0 It was a great function! Why it had been removed??? --91.89.82.157 18:21, 8 March 2010 (UTC)


 * It hasn't been removed - it just got changed, and moved into Semantic Maps. See here. Yaron Koren 01:10, 12 July 2010 (UTC)

Misspellings
Hope not to offend anyone by pointing to two misspellings and one bad phrasing in the article: --Even Thorbergsen 19:33, 23 March 2010 (UTC)
 * ...that might be use...
 * ...to the smae page...
 * Comparators work only for property values, but not for conditions on categories: Only and but should not be used together. Replace but by and or leave out only.
 * Hi Even, thank you for your hints. I do not think that someone will feel offended by your input. It helps making this wiki even better. Cheers --kgh 20:10, 23 March 2010 (UTC)
 * Kept on reading after a break and found this: special sybols--Even Thorbergsen 22:27, 23 March 2010 (UTC)
 * I would not have found the last one if had done a refresh before reading on, as someone in the meantime had performed a cleanup. Still I found this: A Italian city.--Even Thorbergsen 22:38, 23 March 2010 (UTC)
 * Sometimes changes happen fast on a wiki. :-) Thank you. --kgh 23:04, 23 March 2010 (UTC)

Filtering out deleted pages?
If someone (say, me) creates a category, but accidentally misspells it, then deletes it, it then shows up in any category query from then on. How to filter on MediaWiki meta-data like 'deleted' or 'last-updated' is not very well explained on this page.


 * I bet the issue is that, after you misspelled it, you moved it to its correct spelling - which then caused for there to be two category pages, the first being a redirect. You should delete that redirect page as well. Yaron Koren

UPDATE: Figured out the problem. Once SMW knows about something, it refuses to forget about it. I deleted the redirect page. I deleted the history. It was still there. I scoured the MediaWiki database. There was no trace of the old page. In order to make it go away, I had to go into the database and delete the rows in the SMW_IDS table. Even using the 'SMW_refreshData.php' script in the SMW/maintenance folder didn't solve the problem. So, for fun, I deleted all rows from SMW_IDS table, then ran the SMW_setup.php script, which re-created the built-in rows from that table, then ran the SMW_refreshData.php script, which populated the table with all the stuff that used to be there and still belonged there.

The fact that rows are never removed from that table, even after they are removed from the rest of the wiki, is (I think) a defect in SMW. True, in most wiki's you don't delete pages, you create redirects. So it's probably not a huge deal for most people. But at least there is now a documented workaround.


 * {|width="95%"


 * If someone has the Parser Functions extension installed. You can use ||
 * A specific example for your categories would be ||
 * width="60%"|That's as pretty as it gets, unless you add a property into the non-deleted category: such as || Is alive::
 * Then it's as simple as ||
 * colspan="2" align="center"|MlGamble
 * }
 * Then it's as simple as ||
 * colspan="2" align="center"|MlGamble
 * }
 * }


 * Here is another idea I found at http://www.mail-archive.com/mediawiki-l@lists.wikimedia.org/msg02537.html. If you add the condition modification date::+ to your query then it will only return pages that exist. So, + modification date::+ returns a list of all existing pages in the main namespace. And Category:+ modification date::+ returns a list of all existing categories. However, I could not get this to work with a list of templates as it appears that templates do not have the modification date, or any other, property. --Marnicknz 10:55, 1 February 2011 (CET)


 * This does not work for properties either. Everything has a modification date. The only reason it's not working is because, I guess, some things were overlooked. My impression of mediawiki in general is that features get added haphazardly without much big-picture planning. Without a big picture plan, there ends up being more than one way to do things, and whatever way you're doing it that doesn't work is the "wrong" way. Of course, over time, every oversight is hopefully identified and fixed. I just hope this one gets fixed, since it seems like a pretty fundamental oversight for something that bills itself as a semantic wiki, not just an isolated semantic page. If it weren't supposed to be a semantic wiki, I may not expect the semantic features to work on everything. But, I guess there isn't much use for something that's only partly semantic, since that sharply constrains the flexibility that the semantic features are supposed to offer. So where does that leave us? With a broken semantic wiki, unfortunately. Badon 04:37, 12 July 2011 (CEST)


 * My mistake, it does actually work for properties. In fact, it seems it works for everything, including templates. The issue is that you need to add the template namespace to SMW, and then you have to actually modify the the template to get it to have a modification date. This should be helpful: http://semantic-mediawiki.org/wiki/Help:Repairing_SMW's_data Badon 20:03, 15 July 2011 (CEST)

I have all these same problems. I consider them to be serious bugs. I can't believe it's been known for so long and not fixed. I'm doing the exact same thing, with trying to display templates, categories, properties, forms, etc, and I get huge lists of old, deleted stuff, if I get anything at all. This is unexpected. How does this get fixed? After this many months, if nobody else can do it, I suppose I better have a look at the code myself, and see if I can fix this. My project has been halted because of this. Badon 02:43, 12 July 2011 (CEST)


 * It looks like it wasn't fixed because it wasn't formally reported as a bug until quite recently. Now that it's been reported, hopefully no more modification date tricks will be needed to get this to work. Badon 20:05, 15 July 2011 (CEST)


 * I have also run into this problem. Is there any update? I'm using SMW 1.7.0.2 (upgraded in January 2012). I understand it has not been fixed yet? OUA 13:38, 20 March 2012 (CET)


 * It was not fixed in case your wiki shows the reported behaviour. Since the bug id was not shared you and I cannot really have a look. Cheers --&#91;&#91;kgh&#93;&#93; 23:34, 20 March 2012 (CET)


 * Still not fixed it seems. I had a page in a custom namespace accidentially the created with the pagename "&" and deleted. It not was still appearing in results as a redlink and also the result set got mulitple entries for all results, each with strange numbers attached. Both, the deleted page and multiple results vanished afer adding Modification date::+ to the query.

Selecting pages that are properites of another set of pages
I can't find a way to select pages in the following way: Let's say I have this set of data:
 * Category images that contains
 * File 1 that has property file type::jpg
 * File 2 that has property file type::png
 * File 3 that has property file type::jpg
 * Category file types that contains
 * jpg page
 * png page
 * ocx page
 * txt page and so on.

Now I would like to select pages from category file types that are used by pages in category images. The query should return pages jpg and png (not File 1, File 2 and File 3). Of course the file type property is of type Page.

Is it possible to do that? If yes: how? Any help will be appreciated. 212.182.91.35 09:54, 1 September 2010 (UTC)

Wildcards and comparators in article names and categories
It will be helpful to enable the use of wildcards and comparators while searching not only by property but also by category and page name, e.g.:  . -- Anonymous

Help does not mention the Search Inverse Property of v1.5.0 feature
The *very* important feature Inverse_properties is not mentined at all on this help-page. Probably a separate section should ve devoted for it. Ankostis 12:52, 13 December 2010 (CET)

How can I search for pages which have a Modification date less than a specific date?
The following example should help.

Date sorting not working
I'm using the following "#ask" query in my private wiki, but the sorting is not working. Note that the "Due Date" property is of type Date. Am I doing something wrong ?

Problems combining and <!date>
Hello, can someone with more brains than me explain why this fails: ? It seems that the second part is completely ignored. What I want to return is articles with date 1912-08-10 that do not also have date 1912-08-09. (Link to Special:Ask)

The properties are set (via templates) similar to this:

Best regards, Rotsee 16:08, 8 April 2011 (CEST)
 * Or is it in fact returning any page with a property DateProperty set on anything but xxx? I guess so. In that case I guess I have to do my own extension to handle it, unless there is some clever workaround. Rotsee 16:17, 8 April 2011 (CEST)


 * Workaround: Add an extra property: StartingDate at first day of period each, and check for that instead. 213.89.121.199 19:35, 8 April 2011 (CEST)

Can't list contents of categories
I have an odd problem: When trying to show pages in a category, e.g. by  all I get is one line, with the category name (like this: http://bit.ly/fAPXac), rather than a list of pages in that category, which I had expected. Does anyone have an idea what's going wrong here? Rotsee 23:56, 11 March 2011 (CET)
 * Solved: I had to use local name for categories (that wasn't entirely clear from the docs here, and I also had to grant the wiki database user a couple of extra mysql rights Rotsee 00:11, 12 March 2011 (CET)

Default values for missing properties
Is there a way to supply a default value for a property if it does not exist in a row? Would be useful for formatting queries with templates.

E.g. I use a template called Titled Internal Link, which takes to parameters, page and title property. It simply queries the title property and displays it after the pagename. If I have a query which produces a list of pagelinks which I want to format with this template, I have no way to supply the second parameter to the template. Defining defaults in the template itself would not help in my case.


 * I'm pretty sure there's no way to do that. Yaron Koren 19:53, 25 March 2011 (CET)

select distinct value of property
Is it possible to ask like this:

select distinct town from friendlist;

At the moment I ask:

and get a long list of town with many duplicates.

London London London London Paris Paris Berlin Paris

I'd rather like a result like:

Berlin Londen Paris

Is this possible?

--188.99.246.77 20:55, 17 April 2011 (CEST)
 * I might have missed something, but I think not. Most of the time you should be able to achieve what you want by rethinking your semantic structure a bit, though. When I've found myself in a corner like this, it has always been because of not thinking through my structure before starting to build. Can you describe exactly what you are trying to do? Rotsee 16:50, 27 April 2011 (CEST)

--192.93.164.28 16:17, 18 May 2011 (CEST)
 * See http://smw.referata.com/wiki/List_the_set_of_unique_values_for_a_property for one answer to this. It does require use of ArrayExtension to work, but that extension is included with SemanticBundle. Matt V.

--Svdubl 05:58, 18 July 2012 (CEST) there is a different workaround which might work for some. faceted query result format allows to group by property values and thus gives a list of unique values as one of facets

NOT for page-type pages?
See Help talk:Inline queries. Cavila 17:03, 27 November 2011 (CET)

Parenthesis for unions
Hi. Why can't I use to group several OR and AND in queries? It shows an error. Is it supported? Emijrp 01:40, 30 January 2012 (CET)


 * I guess not. When I have several ORs I use a concept to preselect pages. This might be a solution for you too. Cheers --&#91;&#91;kgh&#93;&#93; 14:25, 30 January 2012 (CET)

|value2 Property3::value3 But when I put the OR query at the end of the query it works just fine: Property3::value3 |value2 Anyone can explain this? Thanks. --Stefahn (talk) 13:12, 5 September 2012 (CEST)
 * I have a similar question/problem: The following query doesn't work as expected:


 * I guess that the query works on the first part of the query description first and after having selected the pages it does the second part of the query description on exactly these pages selected by the first part. This would explain the different results when exchanging the two parts of the query description with one another. I as SMW would do it like this. :) Still I am not absolutely sure. Why not post this to the mailing list? Cheers --&#91;&#91;kgh&#93;&#93; (talk) 18:43, 5 September 2012 (CEST)

Wildcard * is counter intuitive
Hi, In most (all?) computer languages that use this wildcard it means "zero or more characters", while in SMW it somehow is "one or more characters". Could this be corrected to keep everyone sane? :D Thanks a lot. --TriMoon 06:20, 24 July 2012 (CEST)
 * Hi, this is something you should post on the developers mailing list. They will most probably not notice your post here at all. Cheers --&#91;&#91;kgh&#93;&#93; 10:25, 24 July 2012 (CEST)