Extension talk:Semantic Compound Queries

Compound Queries in Loop
Been banging my head today trying to get these two extensions to play nice, essentially:

In short, I just want to loop over the query setup and populate it with items from arguments in a template. I'm pretty sure it's a formatting issue that's tripping it up. If I strip everything back to without the loop:

Then it all works perfectly fine.


 * I doubt that's possible... you might have better luck using Scribunto for something like that. Yaron Koren (talk) 15:19, 18 April 2013 (UTC)


 * Ah, thanks for the tip! Rodeoclash (talk) 21:34, 18 April 2013 (UTC)

Export to CSV
Hello, does Compound Query have ability to export to CSV? I tried "format=csv", but it does not work, while it works for regular queries. Version 0.3.2. Patelmm79 (talk) 20:26, 5 November 2012 (UTC)


 * What version of Semantic MediaWiki are you using? Yaron Koren (talk) 04:00, 6 November 2012 (UTC)

SMW 1.5.1.1 breaks SCQ in MW 1.13.4
SMW 1.5.1.1 does not fully opperate correctly with MW 1.13.4. The only thing that I have found breaks is Semantic Compound Queries. It works great with MW 1.14

--Dgennaro


 * Hi - what's the error message you get? Yaron Koren 18:20, 29 June 2010 (UTC)


 * It will not show the results of any part of the query except for the final query. Hard to explain. Simple example below.


 * In this example the output would only show the Marketing Events. Also, "color" do not work, but I have been using a template to get around that.

--Dgennaro


 * Oh. Well, I'm guessing that this will be hard to debug - I should probably just change the SCQ documentation to say that it requires version 1.14 or later of MW. Yaron Koren 22:02, 29 June 2010 (UTC)


 * It is not the relationship between MW 1.13.4 and SCQ...it is between MW 1.13.4 and SMW 1.5.1.1. SCQ is the only thing that I have found that breaks. When I rolled back to SMW 1.4.3 it worked fine again. So, the SMW page needs to be changed to be compatible with MW 1.14.x and newer. --Dgennaro 13:37, 30 June 2010 (UTC)


 * But the latest SMW, by itself, works correctly with MW 1.13, no? Yaron Koren 15:50, 30 June 2010 (UTC)


 * Yes, SCQ is the only thing that I have found so far that fails. --Dgennaro 15:51, 30 June 2010 (UTC)

Similar Problem to above, only final query showing
I have found a similar problem within my wiki I have the following code:

All it is displaying is the final query.

I have the following setup
 * MediaWiki 	1.16.0
 * PHP 	5.2.13 (cgi)
 * MySQL 	4.1.22-standard-log


 * Semantic Compound Queries (Version 0.2.6)
 * Semantic Forms (Version 2.0.1)
 * Semantic Maps (Version 0.6.6)
 * Semantic MediaWiki (Version 1.5.2)
 * Admin Links (Version 0.1.3)
 * Header Tabs (Version 0.7)
 * Hide Empty Sections (Version 1.0)
 * Maps (Version 0.6.6)
 * ParserFunctions (Version 1.3.0)
 * FCKeditor (Version fckeditor/mw-extension $Rev$ 2008)
 * Semantic Forms Input Types (Version 0.2)
 * Semantic Result Formats (Version 1.5.0)
 * Validator (Version 0.3.6 rc1)


 * Well, you only have two queries - are you sure that the first one works, by itself? And what happens if you change to a simpler format, like "table"? Yaron Koren 15:15, 30 September 2010 (UTC)
 * Many thanks. They both worked by themselves. But changing it to table shown me that the co-ordinates weren't showing up for one of them and it pushed me in the right direction. Thanks again Yaron !!

Undefined Property
Notice: Undefined property: SMWQueryResult::$display_options in /var/www/pcwiki/extensions/SemanticCompoundQueries/SCQ_QueryResult.php on line 27 any clue why this would be outputting like this? --Willjermuk 20:12, 10 September 2010 (UTC)

Cannot count pages with specific values
Hi, I want to count the associated pages where a specific value is set and show them in a piechart. In detail:

And the following error occurs:

Warning: Attempt to assign property of non-object in C:\ \mediawiki\extensions\SemanticCompoundQueries\SCQ_QueryProcessor.php on line 131

Warning: Attempt to assign property of non-object in C:\ \mediawiki\extensions\SemanticCompoundQueries\SCQ_QueryProcessor.php on line 131

Fatal error: Call to a member function getPrintRequests on a non-object in C:\ \mediawiki\extensions\SemanticCompoundQueries\SCQ_QueryProcessor.php on line 62

BTW: without the parser-functions #var and #vardefine in an all-in-one-query it doesn't work, too. Each single one of the 3 queries work fine! But I want the result in only one table or pie-chart... Hmm, or is there any other possibility to run such a query?!

Semantic Compound Queries with timeline
Hi, (first of all, sorry for my english) Can I use a a timeline as format of a query?

I can make an #ask query only for a category, but I like to print in a single timeline all the events which are related to different categories.

Something like this:

--Feedmyego 18:42, 18 November 2010 (UTC)


 * Hi - I think that should work, but I've never tried it with timeline, so I don't know for sure. Feel free to try it out. Yaron Koren 21:34, 18 November 2010 (UTC)


 * It doesn't work, but i'm not a master in mediawiki coding, so I don't know if it's a SRF problem, or an error in my query. If anyone succeeds, let me know :) --Feedmyego 16:48, 21 November 2010 (UTC)


 * I'm sure the code is very different for both Compound Queries and SRF/Timeline since this discussion topic was raised, but for what it's worth the following does work on my load (MW 1.20.4, SMW 1.8.0.4, SF 2.5.2, PHP 5.4.7):




 * Also, I'm currently tweaking SRF/Timeline to allow you to choose the color of event bands on the timeline. I have it working without compound queries. So this works:




 * But with Compound Queries it does not work (see next code block). Note the inclusion of "durationcolor" parameter, which is not available in the current version of Timeline. This will color all the bands green in the above query.




 * Doing the compound query above does not give me green or orange bands. It gives the default red. Is there something special that has to be done within an extension attempting to use Compound Queries to make the extension able to pass different parameters for each sub-query? Do I have to make that "durationcolor" parameter special in some way for it to be recognized? Thanks! FYI, I will be posting a similar question on the Timeline Format talk page eventually, which will include the changes I made to be able to change event band color.


 * --Jamesmontalvo3 (talk) 22:04, 8 May 2013 (UTC)

Problem with more than one compound query
When I create more than one compound query on a page, the maps stops working

http://www.wikirio.com.br/Sandbox:Ipanema

Right now there's only one, to show that works ok. But stops if you duplicate:


 * Hi, I don't understand - where's an example of a compound query that's not working? Yaron Koren 15:40, 2 March 2011 (UTC)


 * Hi Yaron, http://www.wikirio.com.br/Sandbox:Ipanema


 * It works fine if I use compound_query only once on the artile.


 * Okay, I see the problem - I'm guessing that this is an issue with Semantic Maps. Yaron Koren 18:50, 2 March 2011 (UTC)

incomplet result w/ [SCQ] in comparison to regular #ask ?
hi i have this query compared to each other with two different result. the compound query has less result compared to the the regular ask syntax query. Even after a property updates the result still unchanged

VS

any thoughts?

--Msevero 09:04, 31 March 2011 (UTC)


 * No idea. Yaron Koren 12:05, 31 March 2011 (UTC)
 * thanks for the reply, --Msevero 23:00, 1 April 2011 (UTC)

Searchlabel
I just noticed that the combination "limit=0" and "searchlabel=foo", as used sometimes in regular inline queries, does not work in SCQ. I think that would be worth considering as an option in future releases. Cavila 11:43, 19 May 2011 (UTC)

sorting of result format broadtable
Hi, is it possible to sort the queried results somehow? So far it shows the results are printed in ascending order but to have this in a descending order would be cool too. The regular printout statements do not seem to work. Hmm ... Cheers --&#91;&#91;kgh&#93;&#93; 13:56, 15 August 2011 (UTC)
 * headers=show
 * format=broadtable
 * sort=property name
 * order=descending

sql error after update
i have updated semantic compound queries from 0.2.7 to 0.2.8 and my query crashed.

error: SMWSQLStore2::getSMWPageIDandSort”. database error „1054: Unknown column 'smw_subobject' in 'where clause' (localhost)”.


 * What version of SMW are you using? Yaron Koren 15:11, 17 August 2011 (UTC)

smw 1.6, semantic result formats 1.6, validator 0.4.9


 * Ah - you should comment out the other SMW-based extensions in LocalSettings.php (other than SMW), then go to Special:SMWAdmin and click the "initialise/upgrade DB" button, then uncomment the extensions. Yaron Koren 16:28, 18 August 2011 (UTC)

works now,thank you

v0.2.10
Heiya, there may I download the new version? Cheers --&#91;&#91;kgh&#93;&#93; 18:06, 4 October 2011 (UTC)


 * I actually wanted to skip to the next version, since 0.2.10 had problems with the latest SMW. Thanks for the reminder - I just released the latest version, 0.3, where hopefully all the problems are fixed. Yaron Koren 19:41, 4 October 2011 (UTC)


 * Ah, I see. I just stumbled over this for another reason. The new version makes me curious regarding the sorting issue I discovered. This one sounds like a fix for it which should be very cool then. Cheers --&#91;&#91;kgh&#93;&#93; 19:48, 4 October 2011 (UTC)

Error

 * http://www.wikirio.com.br/Sandbox:Ipanema2

I get: Fatal error: Cannot call method self::compareQueryResults or method does not exist in /home/wikirio/public_html/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php on line 77 I had to return to the previous version


 * I was updating to see if the new version is fixing this old issue. The compound queries doesnt work when you select 2 in the same page:

http://www.wikirio.com.br/Sandbox:Ipanema2

Edgard


 * Hi - this might be an issue due to your PHP version. Could you try restoring SCQ back to the newest version, then changing line 77 from

uasort( $results, 'self::compareQueryResults' );
 * to

uasort( $results, array( 'SCQQueryProcessor', 'compareQueryResults' ) );
 * ...and see if that fixes it? Yaron Koren 18:56, 13 November 2011 (UTC)


 * Yaron, works fine now. Thanks! Do you know what might be the issue I have when I use two Coumpound Queries on the same page? Regards, Edgard


 * Cool. I don't know - it looks like the issue is coming from Semantic Maps. Yaron Koren 20:21, 13 November 2011 (UTC)


 * Awn... Works fine when I use ASK two times. Doesnt work only for Compound Query :(


 * Yeah, but what if you use two non-map compound queries? Yaron Koren 20:44, 13 November 2011 (UTC)


 * Did you guys ever get to the bottom of the error message above? I have working SMW/SM maps all over my site and downloaded 0.3 to try and get maps with different icons. Trying to recreate a (working) #ask function as a compound gave the same exception as the above. Any clues as to what I can check? I am pretty happy that all my ordinary #ask queries are fine. Thanks - and kudos for some great tools, Tim D


 * BTW the fix above instantly fixed the issue for me - but are there any side effects of the edit to that code? - Tim D

Cool - no, I doubt there are any side effects to it; it's just syntax that seems to work across more versions of PHP. Yaron Koren 20:20, 28 November 2011 (UTC)

Sorting results?
Are the parameters for sorting different from those in regular #ask queries? They don't seem to work here. Cavila MW 1.19.2, MySQL 5.1.66, Php 5.3.3-7, SMW 1.8, SF 1.5.1 22:43, 12 February 2013 (UTC)


 * They should work... I don't fully remember, but I think you apply those to the overall query, not the subquery. The property/printout names should be the same for each subquery, though. Yaron Koren (talk) 03:30, 13 February 2013 (UTC)


 * Yes, I know, that's why I was somewhat surprised. Maybe it's because I was not querying pages, but subobjects, on the basis of an inverse "Has subobject" property. Is sorting of subobjects supported in compound queries? Cavila MW 1.19.2, MySQL 5.1.66, Php 5.3.3-7, SMW 1.8, SF 1.5.1 22:51, 14 February 2013 (UTC)


 * If it's supported in regular queries, it should work in #compound_query. Whether it's supported in regular queries, though, I don't know. Yaron Koren (talk) 01:52, 15 February 2013 (UTC)


 * The "sort" parameter works fine in regular #ask-queries on subobjects, but not in SCQ, I'm afraid. On a more general note, the documentation does not currently make clear if the parameters for regular queries can also be used in compound queries (not to mention those that come with SRF). For instance, "limit" and "searchlabel" do not appear to be available (in fact, a "further results" link is missing altogether). Cavila specs MW 1.19.2, MySQL 5.1.66, Php 5.3.3-7, SMW 1.8, SF 1.5.1 16:56, 15 February 2013 (UTC) (yes, what a hideous signature - I'm looking for a less obtrusive way to do this)
 * I do not think that sorting is possible (see my post of 2011) or at least I have not managed to do it so far. Cheers --&#91;&#91;kgh&#93;&#93; (talk) 10:39, 24 May 2013 (UTC)

Compound query with template in calendar format
Hi Yaron,

Doesn't the compound query work with template in calendar format? When I remove the template the retrieved values appear in a calendar, but with the template they end up in a table format. With a 'ask' in stead of compound query it shows the way it should in calendar format.

Ad


 * That sounds like a bug - is this problem viewable somewhere? Yaron Koren (talk) 22:41, 10 March 2013 (UTC)

How to increase the maximum of results displayed on a map ?
Thanks Nicolas NALLET (talk) 21:14, 9 April 2013 (UTC)


 * Use the "limit=" parameter. Yaron Koren (talk) 21:57, 9 April 2013 (UTC)


 * Hi, the limit doesnt have an impact, It s a compound query on internal object (around 2700 stored in the same page) with geographic coordinates... The aim is to diplay it on a map.

See here


 * Ah - with that number of results, you might need to use $smwgQMaxInlineLimit. However, another possible solution is to use the "cluster" option for maps - though I don't know well it would work with SCQ. Yaron Koren (talk) 12:28, 10 April 2013 (UTC)

format=csv not working
Lsilverman (talk) 23:39, 4 February 2014 (UTC)

Versions: Compound Queries 0.3.4, MW 1.22.2 and SMW 1.9.0.2.

format=csv and format=dsv don't work.

broadtable works, table works. Haven't tried others.

My example:

loops and images
Hi, I am new to Semantic. I have been trying to build a basic query that will list all items in a category and their properties :

And I keep getting several repeated over and over again, receiving some 500 items for what should have been 20. Can you point me in the right way to solve this?

Also what is the right way to list all image files in a category. I have tried using this: But I get a list of thumbnails and change it plain, result in a plain list of names. How can I get a list of name + links?

Thanks --87.68.255.133 00:25, 9 November 2014 (UTC)


 * I believe you're asking in the wrong place - #ask is part of the core Semantic MediaWiki extension, while Semantic Compound Queries is a separate spinoff extension. Yaron Koren (talk) 16:00, 9 November 2014 (UTC)

SCQ and template parameter
I tried to use SCQ 0.4 with SRF calendar together with a template for formatting the calendar entries:

This works fine for Day Off Requests but not for Sprints. Sprints will be shown as. So the template seems to be used only for the first query.

Template:SrfDayOffRequest is a simple |

I also tried the following without success:

--Planetenxin (talk) 11:15, 28 July 2015 (UTC)

Order of output based on order of sub queries?
I was sort of hoping I could use the SCQ to order my output based on specific property values. Based on that subsequent subqueries will not return an earlier retrieved result. E.g. the following query would return a table with pages from category records with prop=A before prop=B and any pages with prop not being either A or B as last. I am seeing random order in the overall result, is there a way to set deterministically the sequence of the pages in the resulting table?

PeterBodifee (talk) 14:59, 28 November 2016 (UTC)


 * I think just adding "|sort=prop" after "|format=table" would fix the problem. Maybe the documentation should mention that explicitly. Yaron Koren (talk) 16:56, 28 November 2016 (UTC)
 * Unfortunately it doesn't make any difference in the output. Closer inspection of the produced table shows the sort order is the pagename. And to be clear I don't want the table to be sorted on values of prop, I want the results from the first sub query first, then the results from the second sub query (not repeating any pages which already are returned by the first sub query), and so on. PeterBodifee (talk) 18:06, 28 November 2016 (UTC)


 * Oh, I get it. I'm surprised that the initial #compound_query call doesn't display the results in that order; but it's been a while since I looked into it. One hack you could do is, assuming all these pages get their values stored with the same template, have the template set a 2nd property, called "Sorting prop" or something, that gets set to 1 if prop is A, 2 if prop is B, and 3 if it's anything else - you could do that with a call to #switch. Then you would just need a regular #ask query, sorting on "Sorting prop". Yaron Koren (talk) 18:15, 28 November 2016 (UTC)
 * Thanks for the suggestion. But that is not going to work for me. First I am going to query multiple categories using, however the structure of the templates in all these categories are the same. However that is not the real challenge. The query is going to be parameter driven, passing on a prioritized set of values for prop (and some other properties with specific value arrays as well - why easy when we can do something advanced ;-) , so I don't know in advance what the user of this query will use as values. For our purpose we want a deterministic result of the order (1st subquery #1, 2nd subquery #2, etc), so we can apply meaning to the order (the results are architecture compliance rules where the priority is based on the order of a prioritized set of values for prop). In one template call it could be F, D and in a next call it could be E, A, H (up to 5 values for 5 sub queries). From observation it looks like that all sub query results are combined and then sorted on pagename. The workaround I can think of now is to create tables per sub query (which I could do with regular #ask), the disadvantage is that given the values for the properties on our pages (they are all arrays!), we would repeat results  over the multiple tables and I would really like to avoid repetition (which attracted me to use SCQ). PeterBodifee (talk) 18:55, 28 November 2016 (UTC)

how to install in 1.25.* or newer
I just installed mw 1.28. I installed SCQ using Composer. However it does not show up in the version list. I tried to load with with "require_once" as instructed. As of version 1.25 the loading with "require_once" is replaced by wfLoadExtension. Then I tried to use that. But that results in an error: extension.json is missing.

How do I get it loaded?

thanks. Michiel


 * This extension is broken for MW 1.28 I'm afraid. Up to MW 1.27 you have to use version 0.4.1 and invoke it the classic way since version 1.0.0 is not working. I will file a bug for this. Cheers --&#91;&#91;kgh&#93;&#93; (talk) 00:19, 20 December 2016 (UTC)


 * Now filed as issue 22 --&#91;&#91;kgh&#93;&#93; (talk) 00:40, 20 December 2016 (UTC)


 * This has been fixed now with version 1.0.1 so you should be able to install the extension using Composer. --&#91;&#91;kgh&#93;&#93; (talk) 08:02, 21 December 2016 (UTC)