Search.Definition
Summary
Search.Definition objects are used to define search queries and their parameters.
Once the query defined, your application just needs to call the getData()
method of the Definition to retrieve the related search results.
Methods
Definition(query: string)
Allows you to create short Definition for the Search content object
Parameters:
Name | Is Optional | Default Value | Type | Description |
---|---|---|---|---|
query | No | - | string | A single string can be used to create definition object. This string value will be used as query param. |
Returned value: a Definition object
Definition(params: Search.Params)
Allows you to create full Definition for the Search content object
Search.Params properties:
Name | Is Optional | Default Value | Type | Description |
---|---|---|---|---|
query | No | - | string | One of two parameters (the other being filter ) which restricts the set of documents matched |
view | Yes | View.SearchAll | enum | Identifies a subset of the overall search data universe. See View |
filter | Yes | - | string | Where query is for unstructured end-user-oriented restriction, filter is for structured programmatic restriction. |
orderBy | Yes | - | string | Defines the order in which matching documents should be returned. |
boost | Yes | - | string | This argument supports exactly the same predicate expression syntax as filter , but where filter restricts which documents are matched at all, boost just applies a large scoring boost to documents it matches, which will almost always guarantee that they appear at the top of the results. |
select | Yes | - | string[] | List of the properties of a document to be returned in the response. |
top | Yes | 10 | number | The maximum number of documents to retrieve. Must be non-negative. |
skip | Yes | 0 | number | The number of documents to skip in the sorted result set before returning the next top . |
groupBy | Yes | - | string | If specified, this must name a single Groupable property. Returned documents are grouped into buckets based on their value for this property. |
groupCount | Yes | 3 (when groupBy is specified) | number | When supplied in combination with groupBy , sets the maximum number of documents to be returned per bucket. |
navigators | Yes | - | string | This can name one or more properties, separated by commas, each of which must be Navigable . |
features | Yes | - | enum | The list of feature names which should be enabled for this request. See Feature |
extendedParams | Yes | - | {[key: string]: any} | Specifies the parameters that will be merged with the request |
Returned value: a Definition object
getData(session: Session)
Sends a request to the data platform to retrieve search results described by the Definition object.
Parameter:
Property | Is Optional | Default Value | Type | Description |
---|---|---|---|---|
session | No | - | Session | Session instance |
Returned value: a ContentResponse
Example of usage:
const query = 'CTO Microsoft';
const definition = Search.definition({ query, view: Search.View.People });
const searchRes = await definition.getData(session);