Skip to main content

 

MindTouch Success Center

site/search (GET) (MT4)

Overview

Search the site index

  • REST Method: GET
  • Method Access: public

Query Parameters

Name Type Description
parser {bestguess|term|filename|lucene}? The parser to use for the query (default: bestguess)
nocache bool? Use caching search path (better for paging results) (default: false)
authenticate bool? Force authentication for request (default: false)
constraint string? Additional search constraints (ex: language:en-us AND type:wiki) default: none
sortby {score, title, date, size, wordcount, rating.score, rating.count}? Sort field. Prefix value with '-' to sort descending. default: -score
offset int? Number of items to skip. Must be a positive number or 0 to not skip any. (default: 0)
limit string? Maximum number of items to retrieve. Must be a positive number or 'all' to retrieve all items. (default: 100)
verbose bool? show verbose page xml. default: true
format {xml | search}? search output format (xml | search) default: xml
q string lucene search string

Return Codes

Name Value Description
OK 200 The request completed successfully
Bad Request 400 Invalid input parameter or request body

Message Format

Output (XML):

<search>
    <page id="{int}" href="{uri}" score="{float}">
        ...
    </page>
    <file id="{int}" href="{uri}" score="{float}">
        ...
    </file>
    ...
</search>

Output (search):

<search>
    <result>
        <uri>{uri}</uri> 
        <title>{text}</title> 
        <wordcount>{int}</wordcount> 
        <host>{text}</host> 
        <mime>{mimetype}</mime> 
        <id.page>{int}</id.page> 
        <id.file>{int}</id.file> 
        <path>{text}</path> 
        <tag>{text}</tag> 
        <type>{text}</type> 
        <description>{text}</description> 
        <author>{text}</author> 
        <date.edited>{date}</date.edited> 
        <size>{int}</size> 
        <score>{float}</score> 
    </result>
    ...
</search>

Implementation Notes

Refer here for more information on the Lucene search string format.

C# Code Sample: Perform a Search

The following code example searches for pages with the title "Subpage 1":

Sample Code

Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
p.At("site", "search").With("q", "title:\"Subpage 1\"").With("format", "xml").Get();

Sample Response from executing Code

Sample response indicating that one page was found:

<search>
    <result>
        <uri>http://deki-hayes/Page_Title/Subpage_1</uri> 
        <title>Subpage 1</title> 
        <wordcount>10</wordcount> 
        <host>localhost</host> 
        <mime /> 
        <id.page>32</id.page> 
        <id.file /> 
        <path>Page_Title/Subpage_1</path> 
        <tag /> 
        <type>wiki</type> 
        <description /> 
        <author>Admin</author> 
        <date.edited>20070830001331</date.edited> 
        <size>73</size> 
        <score>0.9999999</score> 
    </result>
</search>

Implementation notes 

Add notes about requirements or config values

Curl Code Sample: Perform a Search

The following command performs a search of the site for the string value of parameter "q":

Sample Code

curl -u username:password -i http://mindtouch.address/@api/deki/site/search?q=xxx

Sample Response from executing Code

Result for a search string present in one page

Content-Type: application/xml

<search>
  <parsedQuery>content:kyle title:kyle^4.0 path.title:kyle^4.0 description:kyle^3.0 tag:kyle^2.0 comments:kyle -namespace:template -namespace:template_talk -namespace:help -namespace:help_talk</parsedQuery>
  <page id="603" href="http://192.168.59.128/@api/deki/pages/603?redirects=0" revision="2" score="0.2008925">
    <uri.ui>http://192.168.59.128/test_feed</uri.ui>
    <title>test feed</title>
    <path>test_feed</path>
    <namespace>main</namespace>
    <metrics>
      <metric.views>9</metric.views>
      <metric.charcount>31</metric.charcount>
    </metrics>
    <summary><p>kyle kenny stan cartman</p></summary>
    <security href="http://192.168.59.128/@api/deki/pages/603/security">
      <permissions.effective>
        <operations mask="15">LOGIN,BROWSE,READ,SUBSCRIBE</operations>
      </permissions.effective>
      <permissions.page>
        <operations mask="0"/>
      </permissions.page>
      <grants/>
    </security>
    <date.edited>2010-02-03T01:24:19Z</date.edited>
    <date.modified>2010-02-03T01:24:19Z</date.modified>
    <user.author id="1" href="http://192.168.59.128/@api/deki/users/1">
      <nick>Admin</nick>
      <username>Admin</username>
      <email hidden="true"/>
      <hash.email>64e1b8d34f425d19e1ee2ea7236d3028</hash.email>
      <uri.gravatar>http://www.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028</uri.gravatar>
    </user.author>
    <description>4 words added, 13 words removed</description>
    <language/>
    <page.parent id="21" href="http://192.168.59.128/@api/deki/pages/21?redirects=0">
      <uri.ui>http://192.168.59.128/</uri.ui>
      <title>Best Wiki Ever</title>
      <path/>
      <namespace>main</namespace>
    </page.parent>
    <page.redirectedfrom/>
    <subpages href="http://192.168.59.128/@api/deki/pages/603/subpages"/>
    <outbound count="0"/>
    <inbound count="0"/>
    <aliases href="http://192.168.59.128/@api/deki/pages/603/aliases"/>
    <revisions count="2" href="http://192.168.59.128/@api/deki/pages/603/revisions"/>
    <comments count=" 0" href="http://192.168.59.128/@api/deki/pages/603/comments"/>
    <properties count="0" href="http://192.168.59.128/@api/deki/pages/603/properties">
      <language deprecated="true"/>
    </properties>
    <tags count="0" href="http://192.168.59.128/@api/deki/pages/603/tags"/>
    <files count="0"/>
    <contents type="application/x.deki0805+xml" href="http://192.168.59.128/@api/deki/pages/603/contents"/>
    <contents.alt type="application/pdf" href="http://192.168.59.128/@api/deki/pages/603/pdf"/>
  </page>
</search>

Implementation notes 

curl flags

-u
Provides external user authentication. Note that if anonymous access is available and authentication is not forced, this flag may be omitted.
-i
Outputs the HTTP response headers. Useful for debugging.
  • Was this article helpful?