Discuss Inline queries

From semantic-mediawiki.org

Talk pages on this wiki should primarily be used to address possible mistakes as well as missing and superseded information in the documentation.
In case you are seeking support concerning individual questions, please have a look at this page. The Semantic MediaWiki user mailing list is always a good idea for seeking help.

Please, have a look at the archive discussions as well.

Multiple queries, same column

Edited by another user.
Last edit: 22:41, 1 June 2019


I was wondering if it's possible to have the printout from two different properties on the same column of a table. E.g.

 |?Has sender=Sender
 |?Has recipient=Recipient
 |?Has uncertain date; ?Has certain date=Date
 |mainlabel=Letter ID
 |searchlabel=... further results
 |class=sortable wikitable smwtable

I would like that data from ?has certain date and ?has uncertain date were stored in the same column.

Thanks for the help

15:39, 31 May 2019

Not with the datatables format. You will have to use the plainlist format (formerly template).

22:40, 1 June 2019

Thanks! I'll try to deal with that.

14:32, 7 June 2019

Show problem but ask no problem

Hello, I have a little problem in the Semantic 3 version between Show and Ask. I want to output the subject declared as a number so I can do more calculations later.

declared into templed

{{#subobject:{{{Turnier|}}} |Has object type=Eventberechnung |Has event={{{Turniername}}} |Has turnier_tanzahl={{#ask:[[Has object type::Event team]] [[Has event::{{FULLPAGENAME}}]] |format=count |default=0}} }} }}

Working is ok, Number 6 is correct,

Attribut:Has turnier tanzahl

Result: Testturnier 2016#Testturnier 2016BERE + 6 +

In the result template, I receive different results for ask and shown

{{#ask: [[Has object type::Eventberechnung]] [[Has event::{{FULLPAGENAME}}]] | ?Has turnier_tanzahl+ | mainlabel=-}}

Result: Testturnier 2016#Testturnier 2016BERE 6

I change ask by show I get the default zero, but i need only the Number 6;

With format=debug i get the Errors and Warnings

Das Symbol „[[“ wurde an einer Stelle verwendet, an der es nicht sinnvoll ist.

Der Teil „]]“ der Abfrage konnte nicht interpretiert werden. Die Ergebnisse entsprechen möglicherweise nicht den Erwartungen.

But I can not see where a "[[ ]]"does not make sense! How else should I determine the correct data record?






I hope I presented my problem reasonably understandable? Thank you for your help!

23:13, 2 December 2018

Yeah, #show is not meant to be used like this. I recommend to stick to #ask

16:56, 7 December 2018

Large query not showing all results

A query that should have ~1800 lines of results has limit=2000. A portion of the results show, but then says "... further results". Why are the results not all showing on one screen? Tina Tenbergen (talk) 00:08, 24 October 2017 (CEST)

00:08, 24 October 2017

Did you have a look at $smwgQMaxInlineLimit ("maximal number of rows ever printed in a single inline query on a single page, even if a setting limit=... is given") and $smwgQMaxLimit ("maximal number of results ever retrieved, even when using special query pages")? You may have to adjust your local settings.

06:35, 24 October 2017

Thanks Dennis, that fixed it. I added those links to the limit documentation on the article page.

16:25, 24 October 2017

Header name for inverse properties in ask queries

If I display the value of an inverse property as in {{#ask: [[...]] | format=table | ... | ?-Property name=Header name}}, the table fails to display the specified header in the table. The header is blank while regular property value headers are shown as given. Note that the values of the inverse property are all shown and are correct. It is only the column header that is not shown.

Is this a bug?

Note that the workaround is to use format=template and construct the table myself. I use the intro template to name the headers correctly, and user {{#show:}} to get the properties I want in the individuals rows. However, I see no reason why format=table should fail to display the given header name.

18:31, 13 November 2015

link=subject - what is it supposed to do ?

If link is set to subject, what is the wiki supposed to do? I don't get it....

00:55, 22 September 2015

Good question. Never used this.

16:23, 22 September 2015

Examples/Different link parameter options should clarify the intention and usage.

17:04, 22 September 2015

Hey, great! Thanks for this one!

20:02, 22 September 2015

Query for Pages with subobjects


I have a page with the following wiki-code which I fill with a semantic form:

|Name=ZI Test 01
|Bezeichnung=Task 01
|Anmerkungen=Test 2
|TeilProjekt=EDV-Projekte/ZI TEST 01
|Bezeichnung=Task 02
|Status=im Plan
|Anmerkungen=Test 3
|TeilProjekt=EDV-Projekte/ZI TEST 01
|Bezeichnung=Test 3
|Status=im Verzug
|Anmerkungen=Was kostet das ganze denn in €?
|TeilProjekt=EDV-Projekte/ZI TEST 01

To make a #ask query for the subojects ist no problem. Now I also want to make query for the main object {{EDV-Projekte...

My query looks like this:

[[Hat Abfrage::+]]

But I only receive the pagename and no vaklues for the fields. Does anyone has idea what went wrong or how I have to define the query?

Thank you in advance


15:11, 17 March 2015
Edited by author.
Last edit: 10:28, 18 March 2015

Could you explain what you're trying to do? Why are you using "Has query" / "Hat Abrage" for this?

17:06, 17 March 2015
Edited by author.
Last edit: 10:59, 18 March 2015

I want to have a table with all the values from the first part not from the parts with {{#subobject:


I tried also

{{#ask: [[Category:EDV-Projekte]]

... (all pages are in this Category) but with the same result. The result table looks like this:

Name Ziel Kat Aufwand Team Prio IstM IstY Kom Status
EDV-Projekte/ZI Test 01
EDV-Projekte/ZI Test 02
09:41, 18 March 2015

OK, so the first part is a template (Vorlage:EDV-Projekte) that adds property values directly to the page. Maybe there's something wrong with your template. Could you check with 'Attribute anzeigen' to see if the values are correctly stored at all?

10:28, 18 March 2015

No! The properties are not show on the page Special:Properties. Only the properties from the subobject part. my form looks like this:

{{{for template|EDV-Projekte}}}
{| class="formtable"
! Projektname:
| colspan="2"|{{{field|Name|mandatory}}}
! Ziel:
| colspan="2"|{{{field|Ziel|mandatory|input type=textarea}}}
! Kategorie:
| colspan="2"|{{{field|Kat|mandatory|input type=combobox|autocomplete|values=B2B,Controlling,DMS-Windream,Informationsplattform,IT-Infrastruktur,Organisation,Reporting,SANGROSS,Schulung,Sonstiges, Support}}}
! Aufwand:
| colspan="2"|{{{field|Aufwand}}}
! Team:
| colspan="2"|{{{field|Team|input type=combobox|autocomplete|size=20|values=BUC-ZIM,BUC-SCM,SCM-ZIM,HOK-SCM}}}
! Priorität:
| colspan="2"|{{{field|Prio|input type=combobox|autocomplete|size=6|values=1,2,3,4,X}}}
! Zieltermin - Plan:
| width="100px"|{{{field|PlanM|input type=combobox|autocomplete|size=10|values=Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez}}}
|{{{field|PlanY|input type=combobox|autocomplete|size=12|values=2012,2013,2014,2015,2016,2017,2018,2019,2020}}}
! Zieltermin - aktuell:
| width="100px"|{{{field|IstM|input type=combobox|autocomplete|size=10|values=Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez}}}
|{{{field|IstY|input type=combobox|autocomplete|size=12|values=2012,2013,2014,2015,2016,2017,2018,2019,2020}}}
! Kommentar:
| colspan="2"|{{{field|Kom|input type=textarea}}}
! Status:
| colspan="2"|{{{field|Status|mandatory|input type=combobox|autocomplete|values=unbearbeitet,im Plan,im Verzug,neuer Termin,zurückgestellt,abgeschlossen}}}
! Anmerkungen:
| colspan="2"|{{{field|Anm|input type=textarea}}}
{{{end template}}}

{{{for template|#subobject:|label=Teilprojekte / Aufgaben|multiple}}}
|{{{field|Bearbeiter|input type=combobox|autocomplete|size=6|values=CB,KH,MS,MZ}}}
|{{{field|Datum|input type=datepicker|date format=dd.mm.yy}}}
! '''Status:'''
| {{{field|Status|input type=combobox|autocomplete|values=unbearbeitet,im Plan,im Verzug,neuer Termin,zurückgestellt,abgeschlossen}}}
! '''Fällig bis:'''
| {{{field|FaelligBis|input type=datepicker|date format=dd.mm.yy}}}
|{{{field|Anmerkungen|input type=textarea}}}{{{field|TeilProjekt|hidden|default={{PAGENAME}} }}}
{{{end template}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}}

and the template like this:

 |width="50px"|'''Projektname:'''||<span style="font-size:x-large; text-shadow:grey 3px 2px 4px; color:darkblue;">'''{{{Name|}}}'''</span>
 |Zieltermin - Plan:||{{{PlanM|}}} {{{PlanY|}}}
 |Zieltermin - aktuell:||{{{IstM|}}} {{{IstY|}}}

[[Image:Part01.png|25 px|link=]] <big>'''Teilprojekte / Aufgaben:'''</big>

{{#ask: [[-Has subobject::{{PAGENAME}}]] 
| mainlabel=-
| ?Bezeichnung
| ?Bearbeiter
| ?Datum
| ?Status
| ?FaelligBis = Fällig bis
| ?Anmerkungen
| index=0
| link=subject
| headers=show
| format=datatable
| class=sortable wikitable smwtable
| default=keine Teilprojekte / Aufgaben gefunden

10:39, 18 March 2015

To judge by your template, you haven't provided any semantic properties for those values so it is only to be expected that there are no semantic annotations. In your template, you could add a 'silent' form of annotation to your template, such as


(etcetera .. you could fill in the rest)

For our user manual on creating semantic content, see Editing.

Unusually enough, it looks like you also have a template named after the subobject parser, or perhaps there is no template at all and the form adds subobjects directly. I'm surprised that it works, but this isn't exactly the recommended way to go about.

All of this suggests as though you are confusing MW's templates and SMW's syntax functions. Are you aware of the differences?

11:48, 18 March 2015

Templates with paramaters as an "introtemplate"

A thread, Thread:Help talk:Inline queries/Templates with paramaters as an "introtemplate", was moved from here to Archive talk:Template format. This move was made by Kghbln (talk | contribs) on 27 August 2014 at 07:35.

How Can I Make a table using two different categories?

I wanna make a table, but the data I need belongs to two different categories, How can I put the inline query?

08:42, 9 May 2014

Sounds like this is what you are looking for: {{#ask: [[Category:CatOneName||CatTwoName]] ...

More info: Help:Selecting_pages#Unions_of_query_results:_disjunctions

14:47, 9 May 2014

Yeah!! Thank you very much Eric

07:15, 15 May 2014

CSV Export with a large number of fields

Hi, I have a mediawiki page and wish to add a #ask query with a large number of fields (110) and export the data to CSV file. This doesnt work and it gives me a 404 file not found error. when i reduce the number of fields in the query, it works. Please help.

11:20, 18 March 2014

Probably you have reached the $smwgQPrintoutLimit. I case of such big queries it might be a good idea to just split it up and merge the result after export.

19:14, 18 March 2014

Thanks for that very prompt reply. Could you please tell me as to what options do i have about splitting it up and merging it. i mean is this possible using the #ask query? Say i have 1000 results, how do i get the first 500 and then the next 500? Thank you very much once again..

09:09, 19 March 2014

It seems that I have misunderstood your question. In case you have a lot of result sets $smwgQMaxInlineLimit needs to be adjusted.

16:42, 19 March 2014

Results of a query are not parsed as wikitext

I have a query that I want to use to create a dymanic list of properties but the output of the query is not rendered.

{{#ask: [[Category:Weblogic Application]] [[Installed Instance::Ms1]] | format=template | template=Installed_Applications }}

Where the Installed_Applications template is this:

* Installed Application: [[Installed Application::{{{1}}}]]

The output ends up looking like unrendered wiki text:

    Installed Application: [[Installed Application::Calendar-public-web]] 
    Installed Application: [[Installed Application::Ceii-public-web]] 
    Installed Application: [[Installed Application::Fivemin]] 
    Installed Application: [[Installed Application::Forecast]] 

Is there a way to make this dymanic list of properties render into the properties?

Thanks, Pete.

15:22, 24 February 2014

Add link=none to your query.

03:43, 25 February 2014

All-in-one table and export link?

Is there any way to have the same #ask query generate both the table and also include (somewhere) an export link that runs the same query for export?

I would like to create pages that both display the data as a table and also provide the export link with a single query. To do so currently, I'm having to basically include the same #ask query twice, where one query is slightly different in that it specifies that it's an export link.

22:22, 14 January 2014

This it is not possible though it would indeed be a nice feature in some cases.

14:43, 15 January 2014

Is having two {{#ask:}}'s really a problem here? After all, the second one should not query anything, it's just a link to a query that will be executed only if clicked.

03:38, 16 January 2014

Wikitext not working inside property displayed with show only on one page of the wiki

This is one of the pages of the wiki where it works:

It doesn't work only on this page:

The script on the both of the pages is:

  • {{#show:{{BASEPAGENAME}} | format = template | template = ==|?Surl= }} {{#show:{{BASEPAGENAME}} | ?Surl= }}
10:03, 8 July 2013

What are these faces ( ͡° ͜ʖ ͡°) for?

05:52, 19 July 2013
( ͡° ͜ʖ ͡°) for the students
21:03, 19 July 2013

I have deleted the pages now, and we are running SMW_refreshData.php

21:04, 19 July 2013

when doing a sort, pages with no value for a property don't show up

21:07, 24 May 2013

Wikitext not working inside property displayed with show

Edited by author.
Last edit: 14:46, 16 May 2013

Did #show change between SMW 1.7.1 and In my current setup (1.7.1) we do:

{{#set: Intro section={{{Intro section|}}} }}

{{{Intro section|}}} is set using Semantic Forms, and allows the user to type something like:

=== Sub-Section One ===
This is some intro text...

=== Sub-Section Two ===
This is more intro text...

Then this intro section can be included in another page. Of course we'd prefer to do LabeledSectionTransclude, but that doesn't appear to work with Semantic Forms since the Labeled Section can't be wrapped in an template.

In SMW 1.7.1 this worked just fine, using {{#show: My Page | ?Intro section }}. In it does not work: we get unformatted wikitext.

If instead I do {{#ask: [[My Page]] | ?Intro section }} it properly formats the wikitext, but it puts it inside a table.

22:55, 15 May 2013

Workaround: declare a template {{==}} that merely displays its only argument: {{{1|}}}. Then use {{#show: My Page | ?Intro section | format = template | template = ==}}.

04:54, 16 May 2013

That's a good workaround, thanks. Does anyone know if there is good reason for #show to not work this way anymore? Or is it an oversight? Seems like #show is broken if this doesn't work.

14:47, 16 May 2013

I checked #set on an old SMW Version and the notion of {{#set: Intro section={{{Intro section|}}} }} would not create any annotation within a normal wikipage because the #set only works on an invoked Parser object (which does the pre-processing, template parsing etc.) this means any pre-parsing of template content need to be finished before #set is called.

16:39, 16 May 2013

Query not working with particular redirect

I have a peculiar situation where querying (ask or show) using a redirect will not work, but the full page name will. So {{#show:DDCU|?Mass}} will not work, but {{#show:DC to DC Converter Unit|?Mass}} will ("DDCU" redirects to "DC to DC Converter Unit"). The same is the case with #ask. Furthermore, browsing for properties on the redirect page shows nothing for DDCU (says This page has no properties), but on other redirect pages it shows all the same properties as on the pages they redirect to. How do I fix this?

22:23, 17 January 2013

By editing and re-saving the redirect page (titled "DDCU" above) the problem is "solved". Why does that fix the problem? How does the redirect page in this one case not get access to the properties, when all other redirect pages don't seem to have that problem?

22:55, 17 January 2013

>> Why does that fix the problem?

Because by the time you re-save the page, the page is recognized (which by then is a synonymous) as a redirect and the target source starts to inherent the redirects properties (only direct redirects count, a redirect of a redirect will have no effect).

>> How does the redirect page in this one case not get access

I don't really remember (haven't looked at Store3) but what normally happens is that when you initiate a redirect of a page the container (with all its properties) gets delete from the the database and only after a job run/or re-save (see above) this page is recognized with an internal state of "_REDI" which makes the redirected source properties part of the new target page.

Also there is a difference of doing a page move (including a redirect) and just doing a redirect (#REDIRECT) which involves different code to be executed. For a more closer look of the inner workings of the redirect handling see SMWSQLStore3Writers updateRedirects() and changeTitle().

06:59, 18 January 2013

#ask Problem

I have a Problem using the #ask-Command. My query is: {{#ask:[[1. Januar::+]]}}. It works for the year-attributes like {{#ask:[[1901::+]]}}, but not for the "day of the month"-Attributes. What can I do? Red Rooster (talk) 21:18, 27 December 2012 (CET)

22:18, 27 December 2012

"1 January" or "1901" is usually a value of some property of type "Date", rather than, as you're assuming here, the property itself. I'd recommend the following steps:

  • Choose a name for the date-type property that you want to use, for instance "Has date".
  • On the page of that property (in this hypothetical case, "Property:Has date"), declare it as being one of type "Date".
  • Then, on the pages where you need it, create the annotation, for example [[Has date::1901]] (the bit that comes before the colons is the property "Has date"; what comes after is the value of this property).
  • A query for pages that share the value "1901" for this property would look like {{#ask: [[Has date::1901]] }}.

For advice on the use of SMW and any problems that you might encounter, it's best to turn to the mailing lists. The talk pages for this site relate to the documentation for SMW.

14:39, 17 January 2013

Distinct weblinks

I am thinking of a way to show all weblinks present on the wiki.

    {{#ask: [[Has homepage::+]]
     | ?Has homepage
     | ?Category
     | format=table
 Has homepageCategory
Extension "Access Control List"http://www.smwplus.net/index.php/Help:Access Control List extensionSemantic MediaWiki documentation
Plurilingual pages
Obsolete pages
Semantic MediaWiki Plus extensions
Extension "Admin Links"https://www.mediawiki.org/wiki/Extension:Admin LinksEffective pages
Semantic MediaWiki documentation
MediaWiki extensions
... further results

But the problem is that many links come up many times.

Is there a way to do distinct selection on the propery "Has homepage" so that no link will show up more then once in the result?

Maybe the solution is obvious, but I couldn't find it.

Best regards, Martin Wiss

23:21, 30 October 2012

Something like DISTINCT in SQL? Try to ask in mailing lists, I don't remember such feature.

16:47, 31 October 2012

I do not think that this is possible either. However, give it a shot at the mailing list. Cheers

23:01, 31 October 2012