In this post I'll go through the details of the SharePoint 2013 Search REST API. This new REST service is the best way to go in a variety of application scenarious. SharePoint Apps built in JavaScript is one good example. External Applications to SharePoint that require search functionality; can also leverage this service as the endpoint for communication into the Search platform.
The old search.asmx SOAP web service is marked as deprecated in SP2013, and the new Search REST service is the replacement.
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
http://host/site/_api/search/query
Supports HTTP Get and is used to retrieve search results.
postquery
http://host/site/_api/search/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
http://host/site/_api/search/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
querytemplate
The query template text.
String
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
sourceid
Specifies the unique identifier of the Result Source to use for executing the search query.
rankingmodelid
The GUID of the Rank Model to be used for this search query.
startrow
A zero-based index of the first search result to be returned.
Integer [ >= 0]
0
rowlimit
The maximum number of search results to be returned, starting at the index specified in startrow.
10
rowsperpage
The number of results to return per page.
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.
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
refiners
Specifies a list of refiners to return as a comma-separated list of strings.
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.
hiddenconstraints
Specifies additional query terms that will be appended to the query.
sortlist
Specifies the list of properties to sort the search results by.
enablestemming
Specifies whether stemming is enabled for the query.
trimduplicates
Specifies whether duplicate items should be removed from search results. This property can also be used to collapse hits in the result set.
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
timeout
Specifies the amount of time, in milliseconds, before the query request times out.
30000
enablenicknames
Specifies whether the exact terms in the search query are used to find matches, or if nicknames are used as well.
False
enablephonetic
Specifies whether the phonetic forms of the query terms are used to find matches.
enablefql
Specifies whether the query string is according to the FAST Query Language (FQL) syntax.
Bool
hithighlightedproperties
Specifies the list of properties to include in the HitHighlightedProperties for each result item.
bypassresulttypes
Specifies if the search result item type should be returned for the query results.
processbestbets
Specifies if the search promoted results should be returned, if available, as a result set.
clienttype
Name of a client which issued query.
personalizationdata
Gets or sets the unique identifier (GUID) for the current user who submitted the search query.
resultsurl
Specifies the URL for the page where the search results are going to be displayed.
querytag
Any custom tags to be used to identify the query. Multiple tags are separated by semicolons.
enablequeryrules
Specifies if Query Rules are turned on for this query.
enablesorting
Indicates whether results should be sorted.
Suggest Parameters
The following table lists the query parameters available from the suggest entry point:
inumberofquerysuggestions
The number of query suggestions to retrieve.
Integer [ > 0]
5
inumberofresultsuggestions
The number of personal results to retrieve.
fprequerysuggestions
Specifies whether to retrieve pre-query suggestions or post-query suggestions.
fhithighlighting
Specifies whether the query suggestions should be highlighted. If "true", the terms in the returned query suggestions that match terms in the specified query are surrounded with <B> and </B> HTML tags.
fcapitalizefirstletters
Specifies whether to capitalize first letters in each term in query suggestions.
showpeoplenamesuggestions
Specifies if people names should be included in query suggestions.
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.
References: