Skip to content

Commit b087615

Browse files
feat(javascript): add search wrappers to lite client (#3556) (generated) [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent c834388 commit b087615

File tree

2 files changed

+69
-34
lines changed

2 files changed

+69
-34
lines changed

clients/algoliasearch-client-javascript/packages/algoliasearch/lite/src/liteClient.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import type {
2222
} from '../model/clientMethodProps';
2323
import type { GetRecommendationsParams } from '../model/getRecommendationsParams';
2424
import type { GetRecommendationsResponse } from '../model/getRecommendationsResponse';
25+
import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse';
2526
import type { SearchMethodParams } from '../model/searchMethodParams';
27+
import type { SearchResponse } from '../model/searchResponse';
2628
import type { SearchResponses } from '../model/searchResponses';
2729

2830
export const apiClientVersion = '5.0.2';
@@ -125,6 +127,39 @@ export function createLiteClient({
125127
transporter.algoliaAgent.add({ segment, version });
126128
},
127129

130+
/**
131+
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
132+
* Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
133+
*
134+
* @summary Search multiple indices for `hits`.
135+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
136+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
137+
*/
138+
searchForHits<T>(
139+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
140+
requestOptions?: RequestOptions
141+
): Promise<{ results: Array<SearchResponse<T>> }> {
142+
return this.search(searchMethodParams, requestOptions) as Promise<{
143+
results: Array<SearchResponse<T>>;
144+
}>;
145+
},
146+
147+
/**
148+
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
149+
* Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes.
150+
*
151+
* @summary Search multiple indices for `facets`.
152+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
153+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
154+
*/
155+
searchForFacets(
156+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
157+
requestOptions?: RequestOptions
158+
): Promise<{ results: SearchForFacetValuesResponse[] }> {
159+
return this.search(searchMethodParams, requestOptions) as Promise<{
160+
results: SearchForFacetValuesResponse[];
161+
}>;
162+
},
128163
/**
129164
* This method allow you to send requests to the Algolia REST API.
130165
*

clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -505,40 +505,6 @@ export function createSearchClient({
505505
});
506506
},
507507

508-
/**
509-
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
510-
* Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
511-
*
512-
* @summary Search multiple indices for `hits`.
513-
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
514-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
515-
*/
516-
searchForHits<T>(
517-
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
518-
requestOptions?: RequestOptions
519-
): Promise<{ results: Array<SearchResponse<T>> }> {
520-
return this.search(searchMethodParams, requestOptions) as Promise<{
521-
results: Array<SearchResponse<T>>;
522-
}>;
523-
},
524-
525-
/**
526-
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
527-
* Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes.
528-
*
529-
* @summary Search multiple indices for `facets`.
530-
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
531-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
532-
*/
533-
searchForFacets(
534-
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
535-
requestOptions?: RequestOptions
536-
): Promise<{ results: SearchForFacetValuesResponse[] }> {
537-
return this.search(searchMethodParams, requestOptions) as Promise<{
538-
results: SearchForFacetValuesResponse[];
539-
}>;
540-
},
541-
542508
/**
543509
* Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
544510
*
@@ -725,6 +691,40 @@ export function createSearchClient({
725691

726692
return { copyOperationResponse, batchResponses, moveOperationResponse };
727693
},
694+
695+
/**
696+
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
697+
* Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
698+
*
699+
* @summary Search multiple indices for `hits`.
700+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
701+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
702+
*/
703+
searchForHits<T>(
704+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
705+
requestOptions?: RequestOptions
706+
): Promise<{ results: Array<SearchResponse<T>> }> {
707+
return this.search(searchMethodParams, requestOptions) as Promise<{
708+
results: Array<SearchResponse<T>>;
709+
}>;
710+
},
711+
712+
/**
713+
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
714+
* Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes.
715+
*
716+
* @summary Search multiple indices for `facets`.
717+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
718+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
719+
*/
720+
searchForFacets(
721+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
722+
requestOptions?: RequestOptions
723+
): Promise<{ results: SearchForFacetValuesResponse[] }> {
724+
return this.search(searchMethodParams, requestOptions) as Promise<{
725+
results: SearchForFacetValuesResponse[];
726+
}>;
727+
},
728728
/**
729729
* Creates a new API key with specific permissions and restrictions.
730730
*

0 commit comments

Comments
 (0)