api.search Class
Search API to get search results for support
Item Index
Methods
- convertDatesToStrings
- flatten
- formSearchUrl static
- formSearchUrl static
- getKnowledgeSearchResults static
- getSearchResults static
- postKnowledgeSearchResults static
- postSearchResults static
Methods
convertDatesToStrings
()
Converts Date to an ISO string to make it easier for jQuery.param to serialize. Only modifies top level attributes
Example:
convertDatesToStrings({"filter.documentDateFrom": new Date("2016-01-15") }); // returns {"filter.documentDateFrom":"2016-01-15T00:00:00.000Z"}
flatten
()
Helper to flatten nested objects to a single level, modified for our api see https://stackoverflow.com/a/49042916/198348 for a reference
Example:
flatten({ "query": "double click", "locale": "en-us,fr-fr,ja-jp", "scopes": "default", "count": "10", "version": "6.0", "suggestId": "", "filter": { "documentDateFrom": new Date("2016-01-15"), "documentDateTo": new Date("2018-09-24"), "contentType": [ "Article", "QnA" ] }, "facets": { "confidentiality": { "count": null }, "contentType": { "count": 10 }, "language": { "count": null } }, "orderBy": [ { "name": OrderByFieldNames.DocumentDate, "direction": OrderByDirection.Descending }, { "name": OrderByFieldNames.SearchScore, "direction": OrderByDirection.Ascending } ] });
// returns this: // { // "query": "double click", // "locale": "en-us,fr-fr,ja-jp", // "scopes": "default", // "count": "10", // "skip": "", // "version": "6.0", // "suggestId": "", // "filter.documentDateFrom": new Date("2016-01-15"), // "filter.documentDateTo": new Date("2018-09-24"), // "filter.contentType[0]": "Article", // "filter.contentType[1]": "QnA", // "facets.confidentiality.count": null, // "facets.contentType.count": 10, // "facets.language.count": null, // "orderBy[0].name": OrderByFieldNames.DocumentDate, // "orderBy[0].direction": OrderByDirection.Descending, // "orderBy[1].name": OrderByFieldNames.SearchScore, // "orderBy[1].direction": OrderByDirection.Ascending // }
formSearchUrl
-
config
Forms the params to send to the search endpoint
Parameters:
-
config
SearchConfigA search config object
formSearchUrl
-
config
-
knowledgeSearch
Forms the search endpoint URL
Parameters:
-
config
SearchConfigA search config object
-
knowledgeSearch
BoolFlag indicates whether to use knowledge search
getKnowledgeSearchResults
-
config
Retrieves knowledge search results for the parameters specified
Parameters:
-
config
KnowledgeSearchConfigA config object to enlist the input criteria.
-
httpMethod.
HttpMethodHTTP Method to use. Valid options are GET and POST (defaults to GET).
-
query.
StringSearch query.
-
locale.
StringComma delimited locale for search results.
-
scopes.
StringComma delimited scopes for the search results.
-
count.
NumberTotal number of search results to be returned.
-
skip.
NumberA subset/multiplier of count that needs to be returned in every call.
-
searchProvider.
StringThe search provider to be used to perform the search.
-
instantAnswerProvider.
StringInstant answer provider to be used.
-
includeInstantAnswers.
BooleanInclude instant answers along with search results.
-
includeWebSearchResults.
BooleanInclude web search results.
-
enableHitHighlights.
BooleanEnable hit highlights.
-
tenant.
StringSpecify tenant to be used.
-
filter.
SearchFilterThe filter to apply for the search results.
-
facets.
SearchFacetsThe facets to apply for the search results.
-
orderBy.
SearchOrderByExpressionThe order by expressions to apply for the search results.
-
version.
StringTargeting a specific version.
-
flights.
String[]The flights the call should use.
-
suggestId.
StringThe suggest id to correlate to this search.
-
environment.
StringThe environment to use (staging or production), default is production.
-
insiderMode.
StringInsider mode for on-boarding onto Alpha development.
-
muid.
StringMuid for the current user.
-
token.
StringAn authentication token from AAD
-
searchId.
StringThe search id used to track the virtual session
-
Returns:
. Promise of knowledge search results.
getSearchResults
-
config
Retrieves search results for the parameters specified
Parameters:
-
config
SearchConfigA config object to enlist the input criteria.
-
httpMethod.
HttpMethodHTTP Method to use. Valid options are GET and POST (defaults to GET).
-
query.
StringSearch query.
-
locale.
StringComma delimited locale for search results.
-
scopes.
StringComma delimited scopes for the search results.
-
count.
NumberTotal number of search results to be returned.
-
skip.
NumberA subset/multiplier of count that needs to be returned in every call.
-
searchProvider.
StringThe search provider to be used to perform the search.
-
instantAnswerProvider.
StringInstant answer provider to be used.
-
includeInstantAnswers.
BooleanInclude instant answers along with search results.
-
includeWebSearchResults.
BooleanInclude web search results.
-
enablehithighlights.
BooleanEnable hit highlights.
-
tenant.
StringSpecify tenant to be used.
-
filter.
SearchFilterThe filter to apply for the search results.
-
facets.
SearchFacetsThe facets to apply for the search results.
-
orderBy.
SearchOrderByExpressionThe order by expressions to apply for the search results.
-
version.
StringTargeting a specific version.
-
flights.
String[]The flights the call should use.
-
suggestId.
StringThe suggest id to correlate to this search.
-
environment.
StringThe environment to use (staging or production), default is production.
-
insiderMode.
StringInsider mode for on-boarding onto Alpha development.
-
muid.
StringMuid for the current user.
-
searchId.
StringThe search id tracking the virtual session.
-
Returns:
. Promise of search results.
postKnowledgeSearchResults
-
config
Retrieves knowledge search results for the parameters specified via HTTP POST by default
Parameters:
-
config
KnowledgeSearchConfigA config object to enlist the input criteria.
postSearchResults
-
config
Retrieves search results for the parameters specified via HTTP POST by default
Parameters:
-
config
SearchConfigA config object to enlist the input criteria.