Muokkaa

Jaa


SharePoint Search REST API overview

Add search functionality to client and mobile applications using the Search REST service in SharePoint and any technology that supports REST web requests.

When you query in the context of a SharePoint Online user, you get results from:

  • Content in SharePoint Online site collections
  • Content in Microsoft 365 groups
  • Shared OneDrive for Business content (content that's accessible for others than the owner of the OneDrive for Business)
  • Content from SharePoint Server that's been indexed via a cloud search Service application. Learn about cloud hybrid search.

Content Delivery Network (CDN) Support

If the Office 365 Private or Public CDN is enabled to optimize performance for assets then this section applies to you. If your search results contain images that are served from the CDN, then the URL for the image will be the CDN URL that is returned in the results and not the asset library location. For more information on CDN please review Use the Office 365 Content Delivery Network (CDN) with SharePoint Online.

Querying with the Search REST service

Search in SharePoint includes a Search REST service you can use to add search functionality to your client and mobile applications by using any technology that supports REST web requests. You can use the Search REST service to submit Keyword Query Language (KQL) or FAST Query Language (FQL) queries in your SharePoint Add-ins, remote client applications, mobile applications, and other applications. The Search REST service supports both HTTP POST and HTTP GET requests.

GET requests

Construct the URI for query GET requests to the Search REST service as follows:

GET /_api/search/query

For GET requests, you specify the query parameters in the URL. You can construct the GET request URL in two ways:

GET http://server/_api/search/query?query_parameter=value&query_parameter=value
GET http://server/_api/search/query(query_parameter=value&amp;query_parameter=<value>)

POST requests

You construct the URI for query POST requests to the Search REST service as follows:

POST /_api/search/postquery

For POST requests, you pass the query parameters in the request in JavaScript Object Notation (JSON) format. The HTTP POST version of the Search REST service supports all parameters supported by the HTTP GET version. However, some of the parameters have different data types, as described in Table 1.

Table 1. Query parameters with different data types for POST requests

Parameter Data type
SelectProperties string[]
RefinementFilters string[]
SortList Sort
HitHighlightedProperties string[]
Properties Microsoft.SharePoint.Client.Search.Query.KeywordQueryProperties

Use POST requests in the following scenarios:

  • When you'll exceed the URL length restriction with a GET request.
  • When you can't specify the query parameters in a simple URL. For example, if you have to pass parameter values that contain a complex type array, or comma-separated strings, you have more flexibility when constructing the POST request.
  • When you use the ReorderingRules parameter because it is supported only with POST requests.

Search REST results format

By default, results are returned in XML format. To get results in JSON format, add the following header to your request:

accept: application/json;odata=verbose

If you don't need metadata, you can instead use:

accept: application/json;odata=nometadata

Using query parameters with the Search REST service

When you make a call to the Search REST service, you specify query parameters with the request. Search in SharePoint uses these query parameters to construct the search query. With a GET request, you specify the query parameters in the URL. For POST requests, you pass the query parameters in the body in JavaScript Object Notation (JSON) format. The following sections describe the query parameters you can use to submit search queries with the Search REST service.

QueryText parameter

A string that contains the text for the search query.

Sample GET request

GET http://{server}/_api/search/query?querytext='sharepoint'

Sample POST request

{
  'request': {
    'Querytext': 'sharepoint',
    'RowLimit': 20,
    'ClientType': 'ContentSearchRegular'
  }
}

QueryTemplate

A string that contains the text that replaces the query text, as part of a query transform.

Sample GET request

GET http://server/_api/search/query?querytext='sharepoint'&amp;querytemplate='{searchterms} author:johndoe'

Sample POST request

{
  '__metadata': {
      'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
   },
  'Querytext': 'sharepoint',
  'QueryTemplate': '{searchterms} Author:johndoe'
}

EnableInterleaving

A Boolean value that specifies whether the result tables that are returned for the result block are mixed with the result tables that are returned for the original query.

true to mix the ResultTables; otherwise, false. The default value is true.

Change this value only if you want to provide your own interleaving implementation.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enableinterleaving=true

Sample POST request

{
  '__metadata': {
      'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  '​EnableInterleaving': 'True'
}

SourceId

The result source ID to use for executing the search query.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;sourceid='8413cd39-2156-4e00-b54d-11efd9abdb89'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'SourceId': '8413cd39-2156-4e00-b54d-11efd9abdb89'
}

RankingModelId

The ID of the ranking model to use for the query.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;rankingmodelid​= _CustomRankingModelID_

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'RankingModelId': 'CustomRankingModelID '
}

StartRow

The first row that is included in the search results that are returned. You use this parameter when you want to implement paging for search results.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;startrow=10

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'StartRow': '10'
}

Note

Please be aware that in order to provide search experience with high performance, we limit the maximum supported value of StartRow to be 50,000. If you need to page through larger result sets, please see Pagination for large result sets.

RowLimit

The maximum number of rows overall that are returned in the search results. Compared to RowsPerPage, RowLimit is the maximum number of rows returned overall.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;rowlimit=30

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'RowLimit': '30'
}

RowsPerPage

The maximum number of rows to return per page. Compared to RowLimit, RowsPerPage refers to the maximum number of rows to return per page, and is used primarily when you want to implement paging for search results.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;rowsperpage=10

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'RowsPerPage': '10'
}

SelectProperties

The managed properties to return in the search results. To return a managed property, set the property's retrievable flag to true in the search schema.

For GET requests, you specify the SelectProperties parameter in a string containing a comma-separated list of properties. For POST requests, you specify the SelectProperties parameter as a string array.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;selectproperties='Title,Author'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'SelectProperties': {
    'results': ['Title','Author']
  }
}

Culture

The locale ID (LCID) for the query (see Locale IDs Assigned by Microsoft).

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;culture=1044

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'Culture': '1044'
}

RefinementFilters

The set of refinement filters used when issuing a refinement query. For GET requests, the RefinementFilters parameter is specified as an FQL filter. For POST requests, the RefinementFilters parameter is specified as an array of FQL filters.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;refinementfilters='fileExtension:equals("docx")'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'RefinementFilters': {
    'results': ['fileExtension:equals("docx")']
  }
}

Refiners

The set of refiners to return in a search result.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;refiners='author,size'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'Refiners': 'author,size',
}

HiddenConstraints

The additional query terms to append to the query.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;hiddenconstraints='developer'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'HiddenConstraints': 'developer'
}

SortList

The list of properties by which the search results are ordered.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;sortlist='rank:descending,modifiedby:ascending'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'SortList': {
    'results': [
      {
        'Property': 'Created',
        'Direction': '0'
      },
      {
        'Property': 'FileExtension',
        'Direction': '1'
      }
    ]
  }
}

EnableStemming

A Boolean value that specifies whether stemming is enabled.

true if the stemming is enabled; otherwise, false. The default value is true.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enablestemming=false

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'EnableStemming : 'False'
}

TrimDuplicates

A Boolean value that specifies whether duplicate items are removed from the results.

true to remove the duplicate items; otherwise, false. The default value is true.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;trimduplicates=false

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'TrimDuplicates': 'False'
}

Timeout

The amount of time in milliseconds before the query request times out. The default value is 30000.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;timeout=60000

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'Timeout': '60000'
}

EnableNicknames

A Boolean value that specifies whether the exact terms in the search query are used to find matches, or if nicknames are used also. true if nicknames are used; otherwise, false. The default value is false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enablenicknames=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'EnableNicknames': 'True'
}

EnablePhonetic

A Boolean value that specifies whether the phonetic forms of the query terms are used to find matches.

true if phonetic forms are used; otherwise, false. The default value is false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enablephonetic=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'EnablePhonetic': 'True'
}

EnableFql

A Boolean value that specifies whether the query uses the FAST Query Language (FQL).

true if the query is an FQL query; otherwise, false. The default value is false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enablefql=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'EnableFQL': 'True'
}

HitHighlightedProperties

The properties to highlight in the search result summary when the property value matches the search terms entered by the user. For GET requests, Specify in a string containing a comma-separated list of properties. For POST requests, specify as an array of strings.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;hithighlightedproperties='Title'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'HitHighlightedProperties':  {
    'results': ['Title']
  }
}

BypassResultTypes

A Boolean value that specifies whether to perform result type processing for the query.

false to perform result type processing; otherwise, true. The default value is true.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;bypassresulttypes=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'BypassResultTypes': 'true'
}

ProcessBestBets

A Boolean value that specifies whether to return best bet results for the query.

true to return best bets; otherwise, false. This parameter is used only when EnableQueryRules is set to true, otherwise it is ignored. The default value is false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;processbestbets=true&amp;enablequeryrules=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'ProcessBestBets': 'true',
  'EnableQueryRules': 'true'
}

ClientType

The type of the client that issued the query.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;clienttype='custom'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'ClientType': 'custom'
}

PersonalizationData

The GUID for the user who submitted the search query.

Sample GET request

GET http:// _\<server\>_/_api/search/query?querytext='sharepoint'&amp;personalizationdata=' _\<GUID\>_'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'PersonalizationData': ' <GUID> '
}

ResultsURL

The URL for the search results page.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;resultsurl='http://server/site/resultspage.aspx'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint'
  'ResultURL': 'http://server/site/resultspage.aspx'
}

QueryTag

Custom tags that identify the query. You can specify multiple query tags, separated by semicolons.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint'
}

Properties

Additional properties for the query. GET requests support only string values. POST requests support values of any type.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;properties='termid:guid'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'Properties': {
    'results': [
      {
        'Name': 'sampleBooleanProperty',
        'Value':
        {
          'BoolVal': 'True',
          'QueryPropertyValueTypeIndex': 3
        }
      },
      {
        'Name': 'sampleIntProperty',
        'Value':
        {
          'IntVal': '1234',
          'QueryPropertyValueTypeIndex': 2
        }
      }
    ]
  }
}

Note

QueryPropertyValueType specifies the type for the property; each type has a specific index value.

EnableQueryRules

A Boolean value that specifies whether to enable query rules for the query.

true to enable query rules; otherwise, false. The default value is true.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enablequeryrules=false

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'EnableQueryRules': 'false'
}

ReorderingRules

Special rules for reordering search results. These rules can specify that documents matching certain conditions are ranked higher or lower in the results. This property applies only when search results are sorted based on rank. You must use a POST request for this property; it does not work in a GET request.

In the following example, MatchType refers to ReorderingRuleMatchType . In the following example, 'MatchType': '0' specifies ResultContainsKeyword.

Sample POST request

{
  '__metadata': {
  'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'ReorderingRules':  {
    'results': [
    {
      'MatchValue': '<someValue>',
      'Boost': '10',
      'MatchType': '0'
    }
    ]
  }
}

ProcessPersonalFavorites

A Boolean value that specifies whether to return personal favorites with the search results.

true to return personal favorites; otherwise false.

Sample GET request

GET http://_server_/_api/search/query?querytext='sharepoint'&amp;processpersonalfavorites=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'ProcessPersonalFavorites': 'false'
}

QueryTemplatePropertiesUrl

The location of the queryparametertemplate.xml file. This file is used to enable anonymous users to make Search REST queries.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;querytemplatepropertiesurl='spfile://webroot/queryparametertemplate.xml'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  QueryTemplatePropertiesUrl : 'spfile://webroot/queryparametertemplate.xml'
}

HitHighlightedMultivaluePropertyLimit

The number of properties to show hit highlighting for in the search results.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;hithighlightedmultivaluepropertylimit=2

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'HitHighlihtedMultivaluePropertyLimit': '2'
}

EnableOrderingHitHighlightedProperty

A Boolean value that specifies whether the hit highlighted properties can be ordered.

true to enable ordering rules; otherwise false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enableorderinghithighlightedproperty=false

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'EnableOrderingHitHighlightedProperty': 'false'
}

CollapseSpecification

The managed properties that are used to determine how to collapse individual search results. Results are collapsed into one or a specified number of results if they match any of the individual collapse specifications. Within a single collapse specification, results are collapsed if their properties match all individual properties in the collapse specification.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;collapsespecification='Author:1 ContentType:2'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'CollapseSpecification': 'Author:1 ContentType:2'
}

EnableSorting

A Boolean value that specifies whether to sort search results.

true to sort search results using SortList, or by rank if SortList is empty. false to leave results unsorted.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;enablesorting=false

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'EnableSorting': 'false'
}

GenerateBlockRankLog

A Boolean value that specifies whether to return block rank log information in the BlockRankLog property of the interleaved result table. A block rank log contains the textual information on the block score and the documents that were de-duplicated.

true to return block rank log information; otherwise, false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;generateblockranklog=true

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'GenerateBlockRankLog': 'true'
}

UIlanguage

The locale identifier (LCID) of the user interface (see Locale IDs Assigned by Microsoft).

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;uilanguage=1044

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'UILanguage': '1044'
}

DesiredSnippetLength

The preferred number of characters to display in the hit-highlighted summary generated for a search result.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;desiredsnippetlength=80

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'DesiredSnippetLength': '80'
}

MaxSnippetLength

The maximum number of characters to display in the hit-highlighted summary generated for a search result.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;maxsnippetlength=100

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'MaxSnippetLength': '100'
}

SummaryLength

The number of characters to display in the result summary for a search result.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;summarylength=150

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext ': 'sharepoint',
  'Summarylength': '150'
}

EnableDynamicGroups

A Boolean value that specifies whether to include the results from private Microsoft 365 groups.

true to include results from private Microsoft 365 groups; otherwise, false. The default value is false.

Sample GET request

GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;Properties='EnableDynamicGroups:true'

Sample POST request

{
  '__metadata': {
    'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
  },
  'Querytext': 'sharepoint',
  'Properties': {
  'results': [ {
    'Name': 'EnableDynamicGroups',
    'Value': { 'BoolVal': true }
  }]
}

Enabling anonymous Search REST queries

You can configure search to support Search REST queries from anonymous users. Site administrators can decide what query parameters to expose to anonymous users by using the queryparametertemplate.xml file. This section describes how to configure your site to enable anonymous access, and create the queryparametertemplate.xml file.

To enable anonymous Search REST queries

  1. Enable anonymous access on the web application and publishing site. For more information about how to do this, see Manage permission policies for a web application in SharePoint and Plan for user authentication methods in SharePoint on TechNet.

  2. Add a new document library named QueryPropertiesTemplate to the publishing site.

  3. Create an XML file named queryparametertemplate.xml, and copy the following XML to the file.

    <QueryPropertiesTemplate xmlns="https://www.microsoft.com/sharepoint/search/KnownTypes/2008/08" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <QueryProperties i:type="KeywordQueryProperties">
        <EnableStemming>true</EnableStemming>
        <FarmId>FarmID</FarmId>
        <IgnoreAllNoiseQuery>true</IgnoreAllNoiseQuery>
        <KeywordInclusion>AllKeywords</KeywordInclusion>
        <SiteId>SiteID</SiteId>
        <SummaryLength>180</SummaryLength>
        <TrimDuplicates>true</TrimDuplicates>
        <WcfTimeout>120000</WcfTimeout>
        <WebId>WebID</WebId>
        <Properties xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <a:KeyValueOfstringanyType>
            <a:Key>_IsEntSearchLicensed</a:Key>
            <a:Value i:type="b:boolean" xmlns:b="http://www.w3.org/2001/XMLSchema">true</a:Value>
          </a:KeyValueOfstringanyType>
          <a:KeyValueOfstringanyType>
            <a:Key>EnableSorting</a:Key>
            <a:Value i:type="b:boolean" xmlns:b="http://www.w3.org/2001/XMLSchema">true</a:Value>
          </a:KeyValueOfstringanyType>
          <a:KeyValueOfstringanyType>
            <a:Key>MaxKeywordQueryTextLength</a:Key>
            <a:Value i:type="b:int" xmlns:b="http://www.w3.org/2001/XMLSchema">4096</a:Value>
          </a:KeyValueOfstringanyType>
          <a:KeyValueOfstringanyType>
            <a:Key>TryCache</a:Key>
            <a:Value i:type="b:boolean" xmlns:b="http://www.w3.org/2001/XMLSchema">true</a:Value>
          </a:KeyValueOfstringanyType>
        </Properties>
        <PropertiesContractVersion>15.0.0.0</PropertiesContractVersion>
        <EnableFQL>false</EnableFQL>
        <EnableSpellcheck>Suggest</EnableSpellcheck>
        <EnableUrlSmashing>true</EnableUrlSmashing>
        <IsCachable>false</IsCachable>
        <MaxShallowRefinementHits>100</MaxShallowRefinementHits>
        <MaxSummaryLength>185</MaxSummaryLength>
        <MaxUrlLength>2048</MaxUrlLength>
        <SimilarType>None</SimilarType>
        <SortSimilar>true</SortSimilar>
        <TrimDuplicatesIncludeId>0</TrimDuplicatesIncludeId>
        <TrimDuplicatesKeepCount>1</TrimDuplicatesKeepCount>
      </QueryProperties>
      <WhiteList xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a:string>RowLimit</a:string>
        <a:string>SortList</a:string>
        <a:string>StartRow</a:string>
        <a:string>RefinementFilters</a:string>
        <a:string>Culture</a:string>
        <a:string>RankingModelId</a:string>
        <a:string>TrimDuplicatesIncludeId</a:string>
        <a:string>ReorderingRules</a:string>
        <a:string>EnableQueryRules</a:string>
        <a:string>HiddenConstraints</a:string>
        <a:string>QueryText</a:string>
        <a:string>QueryTemplate</a:string>
      </WhiteList>
    </QueryPropertiesTemplate>
    
  4. Update the SiteId, FarmId, and WebId elements with the values for your farm, website and publishing site collection.

  5. Save queryparametertemplate.xml to the QueryPropertiesTemplate document library.

  6. Add the QueryTemplatePropertiesUrl parameter to your Search REST call, specifying spfile://webroot/queryparametertemplate.xml as the value.

queryparametertemplate.xml file

The primary elements in the queryparametertemplate.xml file are:

  • QueryProperties element

    Contains a serialized QueryProperties object.

  • WhiteList element

    Contains the list of query properties that the anonymous user is allowed to set.

When an anonymous Search REST query is submitted, the query object is constructed using what's specified in the QueryProperties element. Then, all the properties that are listed in the whitelist are copied from the incoming query to the newly constructed query object.

In this section

See also