Finding the documentation for the Search REST API of Sharepoint is difficult…. There is a very old blog post that I’m going to replicate here to give more visibility:
Location of the Search Rest service
The Search REST service is located at the following URI: http://host/site/_api/search
The Search REST API
The Search REST service exposed by the URI specified above provides the following methods or entry points:
query |
Supports HTTP Get and is used to retrieve search results. |
|
postquery |
Supports HTTP POST and is used to retrieve search results. This method can be used to overcome URI length restrictions when using the HTTP GET based method « query« . |
|
suggest |
Supports HTTP GET and is used to retrieve query suggestions. |
Query Parameters
The following table lists the query parameters available for the query entry point:
Name |
Description |
Type |
Default |
querytext |
The text of the search query. |
String – Maximum query text length allowed by the Keyword Query OM is 4096 characters. |
Empty |
http://host/site/_api/search/query?querytext=’search is cool’ | |||
querytemplate |
The query template text. |
String |
Empty |
enableinterleaving |
Specifies if the result sets which are generated by executing query rule actions to add result block should be mixed with the result set for the original query. |
bool |
True |
http://host/site/_api/search/query?querytext=’terms’&enableinterleaving=false | |||
sourceid |
Specifies the unique identifier of the Result Source to use for executing the search query. |
String |
Empty |
http://host/site/_api/search/query?querytext=’term’&sourceid=’8413cd39-2156-4e00-b54d-11efd9abdb89′ | |||
rankingmodelid |
The GUID of the Rank Model to be used for this search query. |
String |
Empty |
startrow |
A zero-based index of the first search result to be returned. |
Integer [ >= 0] |
0 |
http://host/site/_api/search/query?querytext=’terms’&startrow=11 | |||
rowlimit |
The maximum number of search results to be returned, starting at the index specified in startrow. |
Integer [ >= 0] |
10 |
http://host/site/_api/search/query?querytext=’terms’&startrow=11&rowlimit=3 | |||
rowsperpage |
The number of results to return per page. |
Integer [ >= 0] |
0 |
selectproperties |
Specifies the list of managed properties to return for each search result item. For a managed property to be returned; the Retrievable flag must be set to « true » in the Search Schema. |
String |
Empty |
http://host/site/_api/search/query?querytext=’terms’&selectproperties=’Path,Url,Title,Author’ | |||
culture |
Specifies the identifier of the language culture of the search query. If present, the value must be a valid LCID of a culture name. A list of LCIDs is available here. |
Integer |
-1 |
http://host/site/_api/search/query?querytext=’terms’&culture=1044 | |||
refiners |
Specifies a list of refiners to return as a comma-separated list of strings. |
String |
Empty |
http://host/site/_api/search/query?querytext=’terms’&refiners=’companies,contentclass,ContentType,FileExtension,FileType’ | |||
refinementfilters |
The list of refinement tokens for drilldown into search results. Refinement tokens are returned as part of the RefinementResults table for the search query. |
String |
Empty |
http://host/site/_api/search/query?querytext=’sharepoint’&refiners=’filetype’&refinementfilters=’filetype:equals(« pptx »)’ | |||
hiddenconstraints |
Specifies additional query terms that will be appended to the query. |
String |
Empty |
http://host/site/_api/search/query?querytext=’terms’&hiddenconstraints=’powerpoint’ | |||
sortlist |
Specifies the list of properties to sort the search results by. |
String |
Empty |
http://host/site/_api/search/query?querytext=’terms’&sortlist=’rank:ascending’ | |||
enablestemming |
Specifies whether stemming is enabled for the query. |
bool |
True |
http://host/site/_api/search/query?querytext=’terms’&enablestemming=false | |||
trimduplicates |
Specifies whether duplicate items should be removed from search results. This property can also |
bool |
True |
http://host/site/_api/search/query?querytext=’terms’&trimduplicates=false | |||
trimduplicatesincludeid |
Specifies the value associated with a collapse group, typically used when a user clicks the duplicates link of an item with duplicates. |
long |
0L |
http://host/site/_api/search/query?querytext=’terms’&trimduplicates=true&trimduplicatesincludeid=47 | |||
timeout |
Specifies the amount of time, in milliseconds, before the query request times out. |
Integer |
30000 |
http://host/site/_api/search/query?querytext=’terms’&timeout=50000 | |||
enablenicknames |
Specifies whether the exact terms in the search query are used to find matches, or if nicknames |
bool |
False |
http://host/site/_api/search/query?querytext=’terms’&enablenicknames=true | |||
enablephonetic |
Specifies whether the phonetic forms of the query terms are used to find matches. |
bool |
False |
http://host/site/_api/search/query?querytext=’terms’&enablephonetic=true | |||
enablefql |
Specifies whether the query string is according to the FAST Query Language (FQL) syntax. |
Bool |
False |
http://host/site/_api/search/query?querytext=’terms’&enablefql=true | |||
hithighlightedproperties |
Specifies the list of properties to include in the HitHighlightedProperties for each result item. |
String |
Empty |
http://host/site/_api/search/query?querytext=’terms’&hithighlightedproperties=’Title,Author’ | |||
bypassresulttypes |
Specifies if the search result item type should be returned for the query results. |
bool |
False |
processbestbets |
Specifies if the search promoted results should be returned, if available, as a result set. |
bool |
True |
clienttype |
Name of a client which issued query. |
String |
Empty |
personalizationdata |
Gets or sets the unique identifier (GUID) for the current user who submitted the search query. |
String |
Empty |
resultsurl |
Specifies the URL for the page where the search results are going to be displayed. |
String |
Empty |
querytag |
Any custom tags to be used to identify the query. Multiple tags are separated by semicolons. |
String |
Empty |
enablequeryrules |
Specifies if Query Rules are turned on for this query. |
bool |
True |
http://host/site/_api/search/query?querytext=’terms’&enablequeryrules=false | |||
enablesorting |
Indicates whether results should be sorted. |
bool |
True |
http://host/site/_api/search/query?querytext=’terms’&enablesorting=false |
Suggest Parameters
The following table lists the query parameters available from the suggest entry point:
Name |
Description |
Type |
Default |
querytext |
The text of the search query. |
String |
Empty |
http://host/site/_api/search/suggest?querytext=’nad’ | |||
inumberofquerysuggestions |
The number of query suggestions to retrieve. |
Integer [ > 0] |
5 |
http://host/site/_api/search/suggest?querytext=’nad’&inumberofquerysuggestions=6 | |||
inumberofresultsuggestions |
The number of personal results to retrieve. |
Integer [ > 0] |
5 |
http://host/site/_api/search/suggest?querytext=’nad’&inumberofresultsuggestions=6 | |||
fprequerysuggestions |
Specifies whether to retrieve pre-query suggestions or post-query suggestions. |
bool |
False |
http://host/site/_api/search/suggest?querytext=’nad’&fprequerysuggestions=true | |||
fhithighlighting |
Specifies whether the query suggestions should be highlighted. If « true », the terms |
bool |
True |
http://host/site/_api/search/suggest?querytext=’nad’&fhithighlighting=true | |||
fcapitalizefirstletters |
Specifies whether to capitalize first letters in each term in query suggestions. |
bool |
False |
http://host/site/_api/search/suggest?querytext=’nad’&fcapitalizefirstletters=true | |||
showpeoplenamesuggestions |
Specifies if people names should be included in query suggestions. |
bool |
False |
http://host/site/_api/search/suggest?querytext=’nad’&showpeoplenamesuggestions=true | |||
culture |
Specifies the identifier of the language culture of the search query. If present, the value must be a valid LCID of a culture name. A nice list of LCIDs is available here. |
Integer |
-1 |
http://host/site/_api/search/suggest?querytext=’nad’&culture=1044 |
References:
Examples
A postquery
request will look like:
POST http://localhost/_api/search/postquery HTTP/1.1 Accept: application/json;odata=verbose Content-Type: application/json;odata=verbose Host: localhost Content-Length: 419 { 'request': { 'Querytext': 'sharepoint', 'StartRow':1, 'RowLimit':8, 'SelectProperties': { 'results': ['Title','ContentSource','DisplayAuthor'] }, 'TrimDuplicates':true, 'Refiners':'companies,contentclass,ContentType(filter=7/0/*),FileExtension(filter=7/0/*),FileType(filter=6/0/*)', 'RefinementFilters': {'results': ['filetype:equals("pptx")'] } } }