The QueryPlugin allows you to treat the Wiki as a database where the links between pages are relations. What could you do with a wiki then? Hmm, WikiAsDatabase, WikiAsRequriementsManager, WikiAsBugTracker, whatever...


The use of SET alias= in 2.1.89 completly confuses the QueryPlugin, not sure why... After looking at the code for the QueryPlugin the only plausable reason for this would be that SET alias= isn't reflected in the ReferenceManager? This bug is being ignored for now because the use of SET alias= is rare. (We use RedirectPlugin with a short 2 second timeout so the user can see that he "should" have used the real name instead.) I suppose that I should point out that matchEnglishPlurals doesn't hurt the QueryPlugin, that query results for pages='TO [Main]' and pages='TO [Mains]' are the same as one would expect. --JohnV

The Query plugin does not obey the use of baseUrl as set in the wikiProperties file. I have a situation where I display a page with a QueryPlugin list on it, but the page is not located where the rest of the Wiki is, thus forcing me to set baseUrl in order to make all links etc point to the right place. However QueryPlugin's links points to the host where the page is displayed instead of the host given in the baseUrl. -- Erik Alm, 28 Oct 2005

Known issue Eric. The code currently availble on does not work with the 2.3 branch (possibly not even with higher revision 2.2 branches). I am sitting on code that works with 2.3, and adds ANY and ALL operators (which is very cool, but mind bending). I will (eventually) contribute this code to Janne, but I just don't have the time right now. --JohnV 28Oct2005

See below for a dependency --MatthewHeun#


Q: Can this plugin somehow ork across Wikis, using Interwiki Refs?... I have 3 JSP Wiki instances running and would like to use this on one Wiki to query all of them.

Possible enhancements...#

Dates criteria#

It was brought to my attention that some means of handling dates would be nice. Maybe operators like BEFORE and AFTER... The question is what dates to look at? Modification date of a page is easily accessable, but the conversation had a more general tone than just page modification date based queries. Hmm, the conversation was almost blogish date related... Hmm, Suppose there was a page [Jan 20, 2004], or [01-20-04], or [20 Jan 2004], or wahtever reasonable date formating you like, btu used as a page name. We could then sign pages like --[Your Name] on [20 Jan 2004] . On the [20 Jan 2004] page you could have a referring pages plugin instnace, it would report all pages linking to that "date", sort of a "On this day in history". Then suppose we added BEFORE, AFTER and ON operators and said [{Query pages='TO [YourName] AND (AFTER [19 Jan 2004]'}] That would list all pages with your name and dates after [19 Jan 2004]. <rambling/> --JohnV

Wildcard characters in name criteria#

The QueryPlugin works with bracketed terms (page names), what if we allowed for the use of simple wildcards in thier evaluation? e.g. Both [SomeThing] and [SomeBody] would be returned by pages='TO [Some*]'. --JohnV

RSS feed#

Would be cool to see the query-engine used somehow to supply an RSS feed. You set up a complex query describing exactly which pages you're interested in, then you get a custom RSS feed for it. Or you set up several predefined query-feeds for your website/blog/etc. --DanHoward

Output Contents and Format#

Hmm, I'm thinking about adding some new optional parameters:

  • maxpages= - limit the result set to the first 'N' pages found.
  • nonefound= - message text to be emited when no pages were found.
  • output= - possible values would be 'list', 'delim', 'count'. 'list' would emit an html <UL> list of pages (current behaviour). 'delim' would emit a comma delimited list of pages. 'count' would emit just a raw number of the pages.
FWIW, it would be nice if the <OL> list option was available, and/or if the generated tags contained a generic class name (ie. queryOutput) to make styling the output easier. Thanks! --BrandonKing
How about a directive that returns the same kind of index that IndexPlugin uses? Maybe Janne has provided some kind of convenience method you may be able to use! /Erik Alm, 2005 Aug 10

Other criteria#

  • Parameters that sort of "extend" the query logic...
    • modifiedBefore=evaluate the pages= query, then limit the result set to pages with modification date before the specified date/time.
    • modifiedAfter= - obvious completment to modifiedBefore=.

Note: That 30 second cache length needs made into a properties file setting.

Okay how about a couple more operators, ALL and ANY. Used like:

  • TO (ANY (BY [Foo])) - Matches all pages with links to any page linked by Foo
  • TO (ALL (BY [Bar])) - Matches all pages with links to all of the pages linked by Bar
ANY acts like an "soft" OR clause, ALL acts like a"soft" AND clause. Thoughts? --JohnV
Very smart suggestion! I also suggest allowing the syntax TO( ANY( TO [Foo] )) - matching pages with links to any page with links to Foo, as well as TO( ALL( TO [Bar] )) -- consequently matching pages with links to to all pages with links to Bar. /Erik Alm, 2005 Aug 10

Contents-based criteria#

How about adding a CONTAINS( ) directive that takes advantage of WikiEngine.findPages(String). AFAIK this funktion connects directly to the Lucene search and the CONTAINS directive should therefore be able to handle the same syntax as the regular search does. A syntax example: CONTAINS( +bike -harley ) AND TO( [Mom] ) -- listing all pages linked to [Mom] that contains the text "bike" but not "harley". /Erik Alm, 2005 Aug 10

Plugin rename#

I think this plugin is not very well named. Currently its query capabilities span only the references and names (links). I think ReferenceQueryPlugin or ReferencePlugin applies better.

Of course if you evolve it towards more content-based or metadata-based criteria, QueryPlugin would be justified; in this regards, there are a couple other ideas I'd suggest to take into account. See:

In a way, you block the QueryPlugin namespace for those query-like plugins :o) More seriously, it would be great to have these 3 ideas merged and standardized in the core engine and form a very rich query mechanism.

-- JDuprez

Unclassified feedback#

--JDuprez Sorry about that, I stopped reformatting this page mid-way...

A 2.0.x Codebase Problem#

I have installed the McKessonApsWikiPlugins on my own JSPWiki.

I'm interested in the QueryPlugin for use in bug tracking as JohnVolkar suggests.

When I edit my page to include

 [{Query pages='TO [Main]'}] 

as the example at QueryPlugin suggests and then click save, I get the following text in my browser window:


Then, if I navigate to the page that I entered the text into, the new line that I entered (namely, [{Query pages='TO [Main]'}]) is not in the page. The edit is not being saved. Perhaps an exception is being thrown internally?

Is there a Wiki with QueryPlugin installed that I could use for testing purposes or to verify what I'm seeing in my installation?

Here's what I've done figure out the problem on my installation:

334 Mon Mar 15 09:40:44 EST 2004 com/mckessonaps/jspwiki/plugin/Query.class

so I'm pretty sure I have a valid jar file.

[{Ticker symbol='IBM'}] 


 [{INSERT com.mckessonaps.jspwiki.plugin.ticker.TickerPlugin symbol=IBM}] 


 {INSERT com.mckessonaps.jspwiki.plugin.ticker.TickerPlugin symbol=IBM.BA}] 

each works as expected. So, I'm pretty sure that I have the McKessonApsWikiPlugins.jar installed correctly.

I'd appreciate any insight to this problem.

Problem solved#

QueryPlugin depends on some code in JSPWiki 2.1. The report above was from testing with JSPWiki 2.0.52. Using JSPWiki 2.1.86-alpha appears to solve the problem.


Let me know what you think about the query plugin, glad you solved your issue too. We've been up on 2.1.x for quite some time so I've not tested at all with 2.0.x. I sort of figured the hack used to give the query plugin access to the reference-manager's internals wouldn't work with pre-2.1.x code. I'd be curious to hear how you wiki as bug system experiences turn out. --JohnV

Does QueryPlugin support operator nesting? What I am trying to do is [{INSERT com.mckessonaps.jspwiki.plugin.Query pages=' TO ((TO [Journal]) AND (TO [Category_InstanceOf]))' }] but instead it returns result of ((TO [Journal]) AND (TO [Category_InstanceOf])) query like it is ignorring surrounding TO operator. Naturally, the same is the case for AggregatePlugin. --MTosic

Huh? I'm trying to figure out what you want it to do. The results it's returning are the results I'd expect, it looks to me like you're asking it to list all pages that link to both [Journal] AND [Category_InstanceOf]. ... Unless you are trying to ask it to list all pages that point to any pages pointed to by any page that point to [Journal] and any page that points to [Category_InstanceOf]? <shudder/>.

If you are infact trying to achieve something akin to the latter then no don't expect it to work. An earlier discussion about mentions the possibility of adding ANY and ALL operators that would let you write:

  • pages='TO ((ANY (TO [Journal])) AND (ANY (TO [Category_InstanceOf])))'
But those new operators were never implemented. --JohnV

I am trying to list all pages that point to (any/all - whatever) page(s) that point to both [Journal] and [Category_InstanceOf]. Any/all is not important to me since I have a single page pointing to both pages in question. What is important, that do not have to use the page name in the query. Semantics of the exercise is given in my comment on LinkType page. --MTosic

Yeah, I was afraid of that. The syntax you would need to use is:

  • pages='TO ((ANY (TO [Journal])) AND (ANY (TO [Category_InstanceOf])))'
But I never wrote the ANY and ALL operators. Sorry, you're on your own here. Source for QueryPlugin is in the jar, feel free to write the operators and contribute them back; I don't have any time to write them, and no especial need either <shrug-sorry/> --JohnV
Any chance to get this to work:
[{Query pages='TO ([SomeTask] AND [{$pagename}])'}]
Of coures, the page SomeTask does exist. I just want to enter the current page name into the query but get always some kind of syntax error message like:
[]'s are not balanced.)'}]
I tried different versions without success:
[{Query pages='TO ([SomeTask] AND [[{$pagename}]])'}]
[{Query pages='TO ([SomeTask] AND \[\{$pagename\}\])'}]
Always I get some error message but no result.
The same problem exists if you try to assign the current page name to some variable:
[{SET myvar = [{$pagename}]]
-- ReinhardEngel
See BugReports; the Administrator confirms this as a bug in the Wiki engine. (Issue closed for now.) -- ReinhardEngel

Um, I was considering doing a minor change to this plugin to allow the use of this sort fo syntax pages='TO [FooB*]'. The plugin currently accepts [] as none/no page, I would have [*] be all pages, I could make [.] be this page if you like. No promises as to when I will get to this though. --JohnV

I vote for at least the [.] functionality! That would make an otherwise very cool plugin even cooler ;o) /Erik Alm, 2005 Aug 10

Query by ACL#

Since groups are now working, it would be nice to call this plugin with a ACL parameter (or extract this from the wiki). Basically any noobie what went to the Table Of Contents page wouldnt see any pages that were tagged with a SuperUser ACL, or in someother group i am not a member of.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-62) was last changed on 12-Jan-2011 19:45 by Harry Metske