@searchkit/api
Advanced tools
Comparing version 4.0.0-next.10 to 4.0.0-next.11
@@ -88,2 +88,3 @@ import { MultipleQueriesQuery } from '@algolia/client-search'; | ||
body: SearchRequest$1; | ||
request: MultipleQueriesQuery; | ||
indexName: string; | ||
@@ -94,2 +95,17 @@ }; | ||
getBaseFilters?: () => ElasticsearchQuery[] | undefined; | ||
hooks?: { | ||
/** | ||
* @description Allows you to modify the search requests before they are sent to Elasticsearch | ||
* @param requests An array of SearchRequest objects, each containing the body (elasticsearch query) and indexName of the request | ||
* @returns An array of modified SearchRequest objects, each containing the body (elasticsearch query) and indexName of the request | ||
*/ | ||
beforeSearch?: (requests: SearchRequest[]) => Promise<SearchRequest[]>; | ||
/** | ||
* @description Allows you to modify the search responses before its transformed into an InstantSearch response | ||
* @param requests An array of SearchRequest objects, each containing the body (elasticsearch query) and indexName of the request | ||
* @param responses An array of Elasticsearch Response objects | ||
* @returns An array of modified Elasticsearch response objects | ||
*/ | ||
afterSearch?: (requests: SearchRequest[], responses: ElasticsearchResponseBody[]) => Promise<ElasticsearchResponseBody[]>; | ||
}; | ||
} | ||
@@ -96,0 +112,0 @@ interface Transporter { |
@@ -847,2 +847,3 @@ "use strict"; | ||
async handleInstantSearchRequests(instantsearchRequests, requestOptions) { | ||
var _a, _b; | ||
const queryRules = this.config.search_settings.query_rules || []; | ||
@@ -852,3 +853,3 @@ const requestQueryRuleActions = instantsearchRequests.map((request) => { | ||
}); | ||
const esRequests = instantsearchRequests.map((request, i) => ({ | ||
let esRequests = instantsearchRequests.map((request, i) => ({ | ||
body: transformRequest( | ||
@@ -860,8 +861,15 @@ request, | ||
), | ||
request, | ||
indexName: request.indexName | ||
})); | ||
const esResponses = await this.performSearch(esRequests); | ||
if ((_a = requestOptions == null ? void 0 : requestOptions.hooks) == null ? void 0 : _a.beforeSearch) { | ||
esRequests = await requestOptions.hooks.beforeSearch(esRequests); | ||
} | ||
let esResponses = await this.performSearch(esRequests); | ||
if ((_b = requestOptions == null ? void 0 : requestOptions.hooks) == null ? void 0 : _b.afterSearch) { | ||
esResponses = await requestOptions.hooks.afterSearch(esRequests, esResponses); | ||
} | ||
const instantsearchResponses = esResponses.map((response, i) => { | ||
var _a; | ||
if ((_a = instantsearchRequests[i].params) == null ? void 0 : _a.facetName) { | ||
var _a2; | ||
if ((_a2 = instantsearchRequests[i].params) == null ? void 0 : _a2.facetName) { | ||
return transformFacetValuesResponse(response, instantsearchRequests[i]); | ||
@@ -868,0 +876,0 @@ } |
{ | ||
"name": "@searchkit/api", | ||
"version": "4.0.0-next.10", | ||
"version": "4.0.0-next.11", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "description": "", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
170309
1930