Skip to main content

site/opensearch (GET) (MT4)

Overview

Search the site index

  • REST Method: GET
  • Method Access: public

Query Parameters

Name Type Description
authenticate bool? Force authentication for request (default: false)
parser {bestguess|term|filename|lucene}? The parser to use for the query (default: bestguess)
q string lucene search string
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)
nocache bool? Use caching search path (better for paging results) (default: false)
constraint string? Additional search constraint (ex: language:en-us AND type:wiki) default: none
format {rss | atom}? search output format (rss | atom) default: atom

Return Codes

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

Message Format

Output (RSS):

<rss version="2.0">
  <channel>
    <title>{text}</title> 
    <description>{text}</description> 
    <opensearch:totalResults>{int}</opensearch:totalResults> 
    <opensearch:itemsPerPage>{int}</opensearch:itemsPerPage> 
    <opensearch:Query role="request" searchTerms="{text}" startPage="{int}"  /> 
    <atom:link rel="{alternate|search|first|next|last|self}" type="{contenttype}" href="{uri}" /> 
    ...
    <item>
      <title>{text}</title> 
      <link>{uri}</link> 
      <description>{text}</description> 
      <relevance:score>{int}</relevance:score> 
      <dekilucene:size>{int}</dekilucene:size> 
      <dekilucene:wordcount>{int}</dekilucene:wordcount> 
      <dekilucene:path>{text}</dekilucene:path> 
      <dekilucene:page.parent id="{int}" path="{text}" title="{text}" href="{uri}" /> 
    </item>
    ...
  </channel>
</rss>

  Output (Atom):

<feed>
  <generator version="{text}">{text}</generator> 
  <updated>{date}</updated> 
  <title type="{text}">{text}</title> 
  <author>
    <name>{text}</name> 
  </author>
  <id>{uri}</id> 
  <opensearch:totalResults>{int}</opensearch:totalResults> 
  <opensearch:itemsPerPage>{int}</opensearch:itemsPerPage> 
  <opensearch:Query role="request" searchTerms="{text}" startPage="{int}"/> 
  <link rel="{alternate|search|first|next|last|self}" type="{contenttype}" href="{uri}" /> 
  ...
  <entry>
    <title type="text">{text}</title> 
    <published>{date}</published> 
    <updated>{date}</updated> 
    <link href="{uri}" /> 
    <id>{uri}</id> 
    <content type="text">{text}</content> 
    <relevance:score>{int}</relevance:score> 
    <dekilucene:size>{int}</dekilucene:size> 
    <dekilucene:wordcount>{int}</dekilucene:wordcount> 
    <dekilucene:path>{text}</dekilucene:path> 
    <dekilucene:page.parent id="{int}" path="{text}" title="{text}" href="{uri}" /> 
  </entry>
  ...
</feed>

   

Implementation Notes

Refer here for more information about OpenSearch.

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://help.mindtouch.us/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
p.At("site", "opensearch").With("q", "title:\"Subpage_1\"").With("format", "rss").Get();

Sample Response from executing Code

Sample response indicating that one page was found:

<rss version="2.0">
  <channel>
    <title>Deki Wiki Search</title> 
    <link>http://help.mindtouch.us/@api/deki/site/opensearch?q=title:subpage_1&format=rss&offset=0&limit=100</link> 
    <description>Deki Wiki Search</description> 
    <opensearch:totalResults xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">100000</opensearch:totalResults> 
    <opensearch:itemsPerPage xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">100</opensearch:itemsPerPage> 
    <opensearch:Query role="request" searchTerms="title%3asubpage_1" startPage="1" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" /> 
    <atom:link rel="alternate" type="text/html; charset=utf-8" href="http://help.mindtouch.us/Special:Search?search=title:subpage_1&limit=100&offset=0" xmlns:atom="http://www.w3.org/2005/Atom" /> 
    <atom:link rel="search" type="application/opensearchdescription+xml" href="http://help.mindtouch.us/@api/deki/site/opensearch/description" xmlns:atom="http://www.w3.org/2005/Atom" /> 
    <atom:link rel="first" href="http://help.mindtouch.us/@api/deki/site/opensearch?q=title:subpage_1&format=rss&offset=0&limit=100" type="application/atom+xml; charset=utf-8" xmlns:atom="http://www.w3.org/2005/Atom" /> 
    <atom:link rel="next" href="http://help.mindtouch.us/@api/deki/site/opensearch?q=title:subpage_1&format=rss&offset=100&limit=100" type="application/atom+xml; charset=utf-8" xmlns:atom="http://www.w3.org/2005/Atom" /> 
    <atom:link rel="last" href="http://help.mindtouch.us/@api/deki/site/opensearch?q=title:subpage_1&format=rss&offset=99900&limit=100" type="application/atom+xml; charset=utf-8" xmlns:atom="http://www.w3.org/2005/Atom" /> 
    <item>
      <title>Subpage 1</title> 
      <link>http://help.mindtouch.us/Subpage_1</link> 
      <description>This page has no content. Enrich Deki Wiki by contributing.</description> 
      <relevance:score xmlns:relevance="http://a9.com/-/opensearch/extensions/relevance/1.0/">1</relevance:score> 
      <dekilucene:size xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">67</dekilucene:size> 
      <dekilucene:wordcount xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">10</dekilucene:wordcount> 
      <dekilucene:path xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">Subpage_1</dekilucene:path> 
    </item>
  </channel>
</rss>

Curl Code Sample: Perform a Search

The following command performs a search on query "foo":

Sample Code

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

Sample Response from executing Code

Example search response where one result was returned:

Content-Type: application/xml

<feed xmlns="http://www.w3.org/2005/Atom">
  <generator version="2.0.0.17704">MindTouch Dream XAtom</generator>
  <updated>2010-02-01T21:07:35Z</updated>
  <title type="text">MindTouch Search</title>
  <link rel="self" href="http://192.168.59.128/@api/deki/site/opensearch?q=starfleet&format=atom&offset=0&limit=100"/>
  <author>
    <name>MindTouch Core</name>
  </author>
  <id>http://192.168.59.128/@api/deki/site/opensearch?q=starfleet&format=atom&offset=0&limit=100</id>
  <dekilucene:parsedQuery xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">content:starfleet title:starfleet^4.0 path.title:starfleet^4.0 description:starfleet^3.0 tag:starfleet^2.0 comments:starfleet -namespace:template -namespace:template_talk -namespace:help -namespace:help_talk</dekilucene:parsedQuery>
  <opensearch:totalResults xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">100000</opensearch:totalResults>
  <opensearch:itemsPerPage xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">100</opensearch:itemsPerPage>
  <opensearch:Query xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" role="request" searchTerms="starfleet" startPage="1"/>
  <link rel="alternate" type="text/html; charset=utf-8" href="http://192.168.59.128/Special:Search?search=starfleet&search=starfleet& format=html&limit=100&offset=0"/>
  <link rel="search" type="application/opensearchdescription+xml" href="http://192.168.59.128/@api/deki/site/opensearch/description"/>
  <link rel="first" href="http://192.168.59.128/@api/deki/site/opensearch?q=starfleet&format=atom&offset=0&limit=100" type="application/atom+xml; charset=utf-8"/>
  <link rel="next" href="http://192.168.59.128/@api/deki/site/opensearch?q=starfleet&format=atom&offset=100&limit=100" type="application/atom+xml; charset=utf-8"/>
  <link rel="last" href="http://192.168.59.128/@api/deki/site/opensearch?q=starfleet&format=atom&offset=99900&limit=100" type="application/atom+xml; charset=utf-8"/>
  <entry>
    <title type="text">Starfleet</title>
    <published>2010-01-19T23:27:31Z</published>
    <updated>2010-01-19T23:27:31Z</updated>
    <link href="http://192.168.59.128/Starfleet"/>
    <id>http://192.168.59.128/Starfleet</id>
    <content type="text">
a collection of nerds</content>
    <relevance:score xmlns:relevance="http://a9.com/-/opensearch/extensions/relevance/1.0/">0.9999999</relevance:score>
    <dekilucene:size xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">-1</dekilucene:size>
    <dekilucene:wordcount xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">4</dekilucene:wordcount>
    <dekilucene:path xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">Starfleet</dekilucene:path>
    <dekilucene:id.page xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex">569</dekilucene:id.page>
    <dekilucene:page.parent xmlns:dekilucene="http://services.mindtouch.com/deki/draft/2007/06/luceneindex" id="21" path="" title="Best Wiki Ever" href="http://192.168.59.128/@api/deki/pages/21"/>
  </entry>
</feed>

Implementation notes 

curl flags

-u
Provides external user authentication.
-i
Outputs the HTTP response headers. Useful for debugging.
  • Was this article helpful?