Was this page helpful?

Wiki.GetSearch

    wiki.GetSearch(query : str, max : num, sortBy : str, constraint : str) : list

    Get list of found page and file objects.

    Usage Restrictions

    8.05.1 or later.

    Parameters

    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

    Result

    Returns a list of page and file objects.  The list is empty if no results where found.

    Usage Example

    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>');
    }
    }}
    

    Samples

      Output

    Find all objects containing the keyword "deki" and constraint search to only content that is tagged with "extensions":

    {{ wiki.getsearch('deki', _, _, 'tag:extensions') }} 
    [ { 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" } ]

     

     

    Was this page helpful?
    Tag page
    Viewing 6 of 6 comments: view all
    {{ foreach(var p in wiki.getsearch('test',10,'-viewcount')) { web.link(p.path,p.name); web.html('<br />
    '); } }} 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
    Posted 05:54, 2 Jun 2009
    Problems with Wiki.GetSearch on Mindtouch 2010 (search for tags with spaces ):

    Forum Post: http://forums.developer.mindtouch.com/showthread.php?p=41250
    Bug Filled: http://bugs.developer.mindtouch.com/view.php?id=8445
    Posted 00:41, 19 Jul 2010
    Is it possible to sort results by creation date? Using the "date" argument sorts the results by modification date.
    Posted 16:57, 6 Aug 2010
    Hi Henry!! i don't know how... but i've created a new list and then ordered by date as following:

    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
    Posted 01:53, 4 Oct 2010
    @henryContreras @himikel
    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{}.
    Posted 07:54, 23 Nov 2010
    @neilw
    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!
    Posted 07:52, 1 Dec 2010
    Viewing 6 of 6 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by