archived form Help_talk:Selecting pages
New page
== 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?! --[[User:Reinout van Schouwen|Reinout van Schouwen]] 10:11, 11 August 2008 (UTC)
== Capitalization ==
It appears that if the predicate is <code><nowiki>[[category:X]]</nowiki></code> then the query fails. If the predicate is <code><nowiki>[[Category:X]]</nowiki></code> 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 ? --[[User:Toka|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 --[[User:Kghbln|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).[[User:Ankostis|Ankostis]] 13:30, 10 December 2010 (CET)
: same here [[User:Svdubl|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 "<nowiki>[[No phone number::true]]</nowiki>" if there's no value for that template field, using the #if function - and then query on that. [[User:Yaron Koren|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 ?
::::<nowiki>{{#if:{{{foo_param|}}}| [[bar prop to apply::{{{someparam|}}}]]| [[no bar prop::true]]}}</nowiki> [[User:Ankostis|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
::<nowiki><includeonly>{{#arraydefine:{{{1|}}}1|{{#ask:{{{3|}}}[[Category:Articles]]|format=list|sep=,|limit=1000}}}}{{#arraydefine:{{{1|}}}2|{{#ask:{{{3|}}}[[Category:Articles]][[{{{2|}}}::+]]|format=list|sep=,|limit=1000}}}}{{#arraydiff:{{{1|}}}|{{{1|}}}1|{{{1|}}}2}}</includeonly></nowiki>
::and call it like <nowiki>{{</nowiki>''name of template''|''name of array''|''name of property''|''additional qualifiers''<nowiki>}}</nowiki> and then #arrayprint the result (it'll be called whatever you specified to be ''name of array'') however you like.
:
--[[User:EvgeniyDankovcev|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.
<nowiki> {{#ask: [[Category:Animal]]|?Age|format=template|template=Animals without age}}</nowiki>.
inside a template Template:Animals without age:
<nowiki> <includeonly>{{#if: {{{2}}} | | {{{1}}} }}</includeonly>
</nowiki>
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 <nowiki>{{#ask:NOT [[Conclusion::+]]}} </nowiki> to look for pages without the 'Conclusion' category set.
I have tried <nowiki> [[Conclusion::]], [[Conclusion::!+]], [[Conclusion::!]] and [[Conclusion::'']] </nowiki>
with no luck. Thanks, [[User:Mark J Dayel|Mark J Dayel]] 21:35, 25 March 2010 (UTC)
: Me also needing this feature. [[User:Ankostis|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! --[[User:Gollum|Gollum]] 13:16, 21 July 2011 (CEST)
: I absolutely support this. There are a sh!loads of usecases, fx <nowiki>{{#ask: [[Category:A]] NOT [[Category:B]]</nowiki> --[[User:Eric|Eric]] 21:54, 27 September 2011 (CEST)
: +1. This would be a very helpful feature! [[User:Stefahn|Stefahn]] ([[User talk:Stefahn|talk]]) 13:45, 23 November 2013 (CET)
: Would be very helpful. Also page names and namespaces should allow negation (with a minus perhaps).<br />[[User:Alex Mashin|Alex Mashin]]<sup>[[User talk:Alex Mashin|talk]]</sup> 19:37, 23 November 2013 (CET)
== 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???
--[[Special:Contributions/91.89.82.157|91.89.82.157]] 18:21, 8 March 2010 (UTC)
:It hasn't been removed - it just got changed, and moved into Semantic Maps. [http://mapping.referata.com/wiki/Help:Distance_query See here]. [[User:Yaron Koren|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:
*...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''.
--[[User:Event|Even Thorbergsen]] 19:33, 23 March 2010 (UTC)
: 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 --[[User:Kghbln|kgh]] 20:10, 23 March 2010 (UTC)
:: Kept on reading after a break and found this: ''special sybols''--[[User:Event|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''.--[[User:Event|Even Thorbergsen]] 22:38, 23 March 2010 (UTC)
::: Sometimes changes happen fast on a wiki. :-) Thank you. --[[User:Kghbln|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. [[User:Yaron Koren|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 [http://www.mediawiki.org/wiki/Extension:ParserFunctions Parser Functions extension] installed. You can use ||<nowiki>{{#ifexist: *pagename*|*true statements*|*false statements*}}</nowiki>
|-
|A specific example for your categories would be ||<nowiki>{{#arraymap: {{#ask: [[:Category:+]]|link=none}}|, |cat| {{#ifexist: cat | [[cat]] | }} |}}</nowiki>
|-
|width="60%"|That's as pretty as it gets, unless you add a property into the non-deleted category: such as ||<nowiki>[[Is alive::{{PAGENAME}}]]</nowiki>
|-
|Then it's as simple as ||<nowiki>{{#ask: [[Is alive::+]]}}</nowiki>
|-
|colspan="2" align="center"|[[User:MlGamble|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 <nowiki>[[modification date::+]] to your query then it will only return pages that exist. So, <nowiki>[[:+]] [[modification date::+]]</nowiki> returns a list of all existing pages in the main namespace. And <nowiki>[[:Category:+]] [[modification date::+]]</nowiki> 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. --[[User:Marnicknz|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. [[User:Badon|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 [[User:Badon|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. [[User:Badon|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. [[User:Badon|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? [[User:OUA|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 --[[User:Kghbln|[[kgh]]]] 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 <nowiki>[[file type::jpg]]</nowiki>
** File 2 that has property <nowiki>[[file type::png]]</nowiki>
** File 3 that has property <nowiki>[[file type::jpg]]</nowiki>
* 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. [[Special:Contributions/212.182.91.35|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.: <tt><nowiki>{{#ask:[[Located in::Germany]] [[!Berlin]] [[Category:!Land Capitals]]|intro=German cities that are not federal or land capital}}</nowiki></tt>. -- ''Anonymous''
== Help does not mention the ''Search Inverse Property'' of v1.5.0 feature ==
The *very* important feature [[Semantic_MediaWiki_1.5.0#Inverse_properties|Inverse_properties]] is not mentined at all on this help-page.
Probably a separate section should ve devoted for it. [[User:Ankostis|Ankostis]] 12:52, 13 December 2010 (CET)
==Date related questions ==
===How can I search for pages which have a Modification date less than a specific date? ===
The following example should help.
<pre>
{{#ask:[[Modification date::≤29 February 2012]]
|?Modification date
|format=broadtable
|sort=Modification date
|order=descending
}}
</pre>
=== 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 ?
<nowiki> {{#ask: [[Category:Team_Actions]] [[Due Date::>{{#time: Y-m-d}}]] [[Action Status::!Canceled]] [[Action Status::!Completed]] </nowiki>
|?Due Date=Deadline
|?Actionee=In charge
|?Action Status=Status
|?Action Description=Description
|mainlabel=Title
|sort=Due Date
|order=ascending
|limit=5
<nowiki>}}</nowiki>
=== Problems combining <date> and <!date> ===
Hello, can someone with more brains than me explain why this fails: <code><nowiki>[[DateProperty::1912-08-10]] [[DateProperty::!1912-08-09]]</nowiki></code>? 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. ([http://bit.ly/i7quqe Link to Special:Ask])
The properties are set (via templates) similar to this:
<code><nowiki>
{{#set_recurring_event:property=DateProperty
|start=1912-02-01T00:00:00
|end=1912-09-31T00:00:00
|unit=day
|period=1
}</nowiki></code>
Best regards, [[User:Rotsee|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. [[User:Rotsee|Rotsee]] 16:17, 8 April 2011 (CEST)
::Workaround: Add an extra property: StartingDate at first day of period each, and check for that instead. [[Special:Contributions/213.89.121.199|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 <code><nowiki>{{#ask: [[Category:xxx]]}}</nowiki></code> 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? [[User:Rotsee|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 [[User:Rotsee|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. [[User:Yaron Koren|Yaron Koren]] 19:53, 25 March 2011 (CET)
== select distinct value of property ==
Is it possible to ask like this:
<pre>select distinct town from friendlist;</pre>
At the moment I ask:
<pre>{{#ask: [[Kategorie:Friends]] | ?Town= | mainlabel=-}}</pre>
and get a long list of town with many duplicates.
<pre>
London
London
London
London
Paris
Paris
Berlin
Paris
</pre>
I'd rather like a result like:
<pre>
Berlin
Londen
Paris
</pre>
Is this possible?
--[[Special:Contributions/188.99.246.77|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? [[User:Rotsee|Rotsee]] 16:50, 27 April 2011 (CEST)
--[[Special:Contributions/192.93.164.28|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.
--[[User:Svdubl|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#NOT for page-type pages?]]. [[User:Cavila|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? [[User:Emijrp|Emijrp]] 01:40, 30 January 2012 (CET)
: I guess not. When I have several ORs I use a [[Help:Concepts|concept]] to preselect pages. This might be a solution for you too. Cheers --[[User:Kghbln|[[kgh]]]] 14:25, 30 January 2012 (CET)
:: I have a similar question/problem: The following query doesn't work as expected:<br /><nowiki>[[Property1::value1||value2]]</nowiki><br /><nowiki>[[Property3::value3]]</nowiki><br />But when I put the OR query at the end of the query it works just fine:<br /><nowiki>[[Property3::value3]]</nowiki><br /><nowiki>[[Property1::value1||value2]]</nowiki><br />Anyone can explain this?<br />Thanks.<br />--[[User:Stefahn|Stefahn]] ([[User talk:Stefahn|talk]]) 13:12, 5 September 2012 (CEST)
::: 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 --[[User:Kghbln|[[kgh]]]] ([[User talk:Kghbln|talk]]) 18:43, 5 September 2012 (CEST)
== Wildcard * is counter intuitive ==
Hi,<br/>
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".<br/>
Could this be corrected to keep everyone sane? :D<br/>
Thanks a lot.<br/>
--[[User:TriMoon|TriMoon]] 06:20, 24 July 2012 (CEST)
: Hi, this is something you should post on the [[Mailing list|developers mailing list]]. They will most probably not notice your post here at all. Cheers --[[User:Kghbln|[[kgh]]]] 10:25, 24 July 2012 (CEST)