wiki.GetSearch(query : str, max : num, sortBy : str, constraint : str) : list
Get list of found page and file objects.
8.05.1 or later.
| Name | Type | Description |
| query | str | search query |
| max | num | (optional, default: 10): max results |
| sortBy | str | (optional, one of "score", "title", "date", "size", "wordcount"; use "-title" for reverse order; default: "score"): sort field |
| constraint | str | (optional, default: ""): additional search constraint |
Returns a list of page and file objects. The list is empty if no results where found.
Create a list of the ten most viewed pages in your wiki containing the word 'test'.
{{
foreach(var p in wiki.getsearch('test',10,'-viewcount')) {
web.link(p.path,p.name);
web.html('<br>');
}
}}
| Output | ||
| [ { api : "http://developer.mindtouch.com/@api/deki/pages/9977", author : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$user", comments : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagecomments", contents : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagecontents", date : "Fri, 09 May 2008 08:18:17 GMT", editsummary : "1 words added, 1 words removed", feed : "http://developer.mindtouch.com/@api/deki/pages/9977/feed", files : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$files", fronturi : "http://developer.mindtouch.com/App_Catalog/Shell_Output", id : 9977, ishidden : False, language : nil, mime : "application/x.deki0702+xml", name : "Shell_Output", namespace : "", parent : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$page", parents : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$parents", path : "App_Catalog/Shell_Output", properties : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pageprops", rating : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$rating", redirect : nil, revision : 9, revisions : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$revisions", subpages : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$subpages", tags : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetags", talkuri : "http://developer.mindtouch.com/Talk:App_Catalog/Shell_Output", text : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetext", title : "Shell Output", toc : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetoc", unprefixedpath : "App_Catalog/Shell_Output", uri : "http://developer.mindtouch.com/App_Catalog/Shell_Output", viewcount : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pageviewcount", xml : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagexml" }, { api : "http://developer.mindtouch.com/@api/deki/pages/13154", author : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$user", comments : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagecomments", contents : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagecontents", date : "Fri, 11 Jul 2008 02:50:44 GMT", editsummary : "100 words added", feed : "http://developer.mindtouch.com/@api/deki/pages/13154/feed", files : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$files", fronturi : "http://developer.mindtouch.com/App_Catalog/Subversion_(with_support_for_bugtraq_properties)", id : 13154, ishidden : False, language : nil, mime : "application/x.deki0805+xml", name : "Subversion_(with_support_for_bugtraq_properties)", namespace : "", parent : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$page", parents : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$parents", path : "App_Catalog/Subversion_(with_support_for_bugtraq_properties)", properties : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pageprops", rating : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$rating", redirect : nil, revision : 6, revisions : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$revisions", subpages : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$subpages", tags : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetags", talkuri : "http://developer.mindtouch.com/Talk:App_Catalog/Subversion_(with_support_for_bugtraq_properties)", text : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetext", title : "Subversion (with support for bugtraq properties)", toc : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetoc", unprefixedpath : "App_Catalog/Subversion_(with_support_for_bugtraq_properties)", uri : "http://developer.mindtouch.com/App_Catalog/Subversion_(with_support_for_bugtraq_properties)", viewcount : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pageviewcount", xml : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagexml" }, { api : "http://developer.mindtouch.com/@api/deki/pages/34572", author : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$user", comments : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagecomments", contents : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagecontents", date : "Thu, 30 Dec 2010 14:11:46 GMT", editsummary : "14 words added", feed : "http://developer.mindtouch.com/@api/deki/pages/34572/feed", files : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$files", fronturi : "http://developer.mindtouch.com/User:qrof/OracleService", id : 34572, ishidden : False, language : nil, mime : "application/x.deki0805+xml", name : "OracleService", namespace : "User", namespaceuser : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$user", parent : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$page", parents : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$parents", path : "User:qrof/OracleService", properties : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pageprops", rating : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$rating", redirect : nil, revision : 7, revisions : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$revisions", subpages : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$subpages", tags : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetags", talkuri : "http://developer.mindtouch.com/User_talk:qrof/OracleService", text : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetext", title : "OracleService", toc : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagetoc", unprefixedpath : "qrof/OracleService", uri : "http://developer.mindtouch.com/User:qrof/OracleService", viewcount : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pageviewcount", xml : "local://bff00cd7837d4b91a2d4325d5ef8ca42/deki/$pagexml" } ] |
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by
'); } }} does not breakline properly.
better is something like
<div foreach="var p in wiki.getsearch('test',10,'-viewcount')">{{ web.link(p.path,p.name) }} <br /></div> edited 06:10, 2 Jun 2009
Forum Post: http://forums.developer.mindtouch.com/showthread.php?p=41250
Bug Filled: http://bugs.developer.mindtouch.com/view.php?id=8445
var mCreatInd=[];
foreach (var post in mBlog)
let mCreatInd..=[{ index: (__index), date: (Date.Format(post.revisions[0].date,"yyyy-MM-dd")) }];
var mCreatOrd=List.OrderBy(mCreatInd,"date descending");
then you can access to ordered posts using: mBlog[mCreatOrd[__index].index].title
You can see it in an adaptation of @BlakeH blog template here: http://www.gureweb.net/Template:@blakeh/Blog
is possible to do it any other easy way? edited 01:54, 4 Oct 2010
To sort by creation date:
var pages = wiki.getsearch(whatever);
var sorted = list.sort{list: pages,
compare:"date.compare($left.revisions[0].date, $right.revisions[0].date)"};
If you want most recent first, then add a "reverse:true" to the argument list for list.sort{}.
Thanks for your answer!
Your solution works, but it's not usefull when performing searches and paginating results. If the wiki.getsearch returns 200 pages, then we should be able to use offset and limit parameters, based on the creation date.
Thanks again!