/
SearchOptions.ts
381 lines (312 loc) · 10.8 KB
/
SearchOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
export type SearchOptions = {
/**
* Create a new query with an empty search query.
*/
readonly query?: string;
/**
* Allows a search for similar objects, but the query has to be constructed on your end and included alongside an empty query.
*
* The similarQuery should be made from the tags and keywords of the relevant object.
*/
readonly similarQuery?: string;
/**
* Filter hits by facet value.
*/
readonly facetFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
/**
* Create filters for ranking purposes, where records that match the filter are ranked highest.
*/
readonly optionalFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
/**
* Filter on numeric attributes.
*/
readonly numericFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
/**
* Filter hits by tags. tagFilters is a different way of filtering, which relies on the _tags
* attribute. It uses a simpler syntax than filters. You can use it when you want to do
* simple filtering based on tags.
*/
readonly tagFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
/**
* Determines how to calculate the total score for filtering.
*/
readonly sumOrFiltersScores?: boolean;
/**
* Filter the query with numeric, facet and/or tag filters.
*/
readonly filters?: string;
/**
* Specify the page to retrieve.
*/
readonly page?: number;
/**
* Set the number of hits per page.
*/
readonly hitsPerPage?: number;
/**
* Specify the offset of the first hit to return.
*/
readonly offset?: number;
/**
* Set the number of hits to retrieve (used only with offset).
*/
readonly length?: number;
/**
* List of attributes to highlight.
*/
readonly attributesToHighlight?: readonly string[];
/**
* List of attributes to snippet, with an optional maximum number of words to snippet.
*/
readonly attributesToSnippet?: readonly string[];
/**
* Gives control over which attributes to retrieve and which not to retrieve.
*/
readonly attributesToRetrieve?: readonly string[];
/**
* The HTML string to insert before the highlighted parts in all highlight and snippet results.
*/
readonly highlightPreTag?: string;
/**
* The HTML string to insert after the highlighted parts in all highlight and snippet results
*/
readonly highlightPostTag?: string;
/**
* String used as an ellipsis indicator when a snippet is truncated.
*/
readonly snippetEllipsisText?: string;
/**
* Restrict highlighting and snippeting to items that matched the query.
*/
readonly restrictHighlightAndSnippetArrays?: boolean;
/**
* Facets to retrieve.
*/
readonly facets?: readonly string[];
/**
* Maximum number of facet values to return for each facet during a regular search.
*/
readonly maxValuesPerFacet?: number;
/**
* Force faceting to be applied after de-duplication (via the Distinct setting).
*/
readonly facetingAfterDistinct?: boolean;
/**
* Minimum number of characters a word in the query string must contain to accept matches with 1 typo
*/
readonly minWordSizefor1Typo?: number;
/**
* Minimum number of characters a word in the query string must contain to accept matches with 2 typos.
*/
readonly minWordSizefor2Typos?: number;
/**
* Whether to allow typos on numbers (“numeric tokens”) in the query string.
*/
readonly allowTyposOnNumericTokens?: boolean;
/**
* List of attributes on which you want to disable typo tolerance.
*/
readonly disableTypoToleranceOnAttributes?: readonly string[];
/**
* Controls if and how query words are interpreted as prefixes.
*/
readonly queryType?: 'prefixLast' | 'prefixAll' | 'prefixNone';
/**
* Selects a strategy to remove words from the query when it doesn’t match any hits.
*/
readonly removeWordsIfNoResults?: 'none' | 'lastWords' | 'firstWords' | 'allOptional';
/**
* Enables the advanced query syntax.
*/
readonly advancedSyntax?: boolean;
/**
* AdvancedSyntaxFeatures can be exactPhrase or excludeWords
*/
readonly advancedSyntaxFeatures?: ReadonlyArray<'exactPhrase' | 'excludeWords'>;
/**
* A list of words that should be considered as optional when found in the query.
*/
readonly optionalWords?: string | readonly string[];
/**
* List of attributes on which you want to disable the exact ranking criterion.
*/
readonly disableExactOnAttributes?: readonly string[];
/**
* Controls how the exact ranking criterion is computed when the query contains only one word.
*/
readonly exactOnSingleWordQuery?: 'attribute' | 'none' | 'word';
/**
* List of alternatives that should be considered an exact match by the exact ranking criterion.
*/
readonly alternativesAsExact?: ReadonlyArray<
'ignorePlurals' | 'singleWordSynonym' | 'multiWordsSynonym'
>;
/**
* Whether rules should be globally enabled.
*/
readonly enableRules?: boolean;
/**
* Enables contextual rules.
*/
readonly ruleContexts?: readonly string[];
/**
* Enables de-duplication or grouping of results.
*/
readonly distinct?: boolean | number;
/**
* Whether the current query will be taken into account in the Analytics
*/
readonly analytics?: boolean;
/**
* List of tags to apply to the query in the analytics.
*/
readonly analyticsTags?: readonly string[];
/**
* Whether to take into account an index’s synonyms for a particular search.
*/
readonly synonyms?: boolean;
/**
* Whether to highlight and snippet the original word that matches the synonym or the synonym itself.
*/
readonly replaceSynonymsInHighlight?: boolean;
/**
* Precision of the proximity ranking criterion.
*/
readonly minProximity?: number;
/**
* Choose which fields the response will contain. Applies to search and browse queries.
*/
readonly responseFields?: readonly string[];
/**
* Maximum number of facet hits to return during a search for facet values.
*/
readonly maxFacetHits?: number;
/**
* Whether to include or exclude a query from the processing-time percentile computation.
*/
readonly percentileComputation?: boolean;
/**
* Enable the Click Analytics feature.
*/
readonly clickAnalytics?: boolean;
/**
* The `personalizationImpact` parameter sets the percentage of the impact that personalization has on ranking records. The
* value must be between 0 and 100 (inclusive). This parameter will not be taken into account if `enablePersonalization`
* is **false**.
*/
readonly personalizationImpact?: number;
/**
* Enable personalization for the query
*/
readonly enablePersonalization?: boolean;
/**
* Restricts a given query to look in only a subset of your searchable attributes.
*/
readonly restrictSearchableAttributes?: readonly string[];
/**
* Restricts a given query to look in only a subset of your searchable attributes.
*/
readonly sortFacetValuesBy?: 'count' | 'alpha';
/**
* Controls whether typo tolerance is enabled and how it is applied.
*/
readonly typoTolerance?: boolean | 'min' | 'strict';
/**
* Search for entries around a central geolocation, enabling a geo search within a circular area.
*/
readonly aroundLatLng?: string;
/**
* Search for entries around a given location automatically computed from the requester’s IP address.
*/
readonly aroundLatLngViaIP?: boolean;
/**
* Define the maximum radius for a geo search (in meters).
*/
readonly aroundRadius?: number | 'all';
/**
* Precision of geo search (in meters), to add grouping by geo location to the ranking formula.
*/
readonly aroundPrecision?:
| number
| ReadonlyArray<{ readonly from: number; readonly value: number }>;
/**
* Minimum radius (in meters) used for a geo search when aroundRadius is not set.
*/
readonly minimumAroundRadius?: number;
/**
* Search inside a rectangular area (in geo coordinates).
*/
readonly insideBoundingBox?: ReadonlyArray<readonly number[]> | string;
/**
* Search inside a polygon (in geo coordinates).
*/
readonly insidePolygon?: ReadonlyArray<readonly number[]>;
/**
* Treats singular, plurals, and other forms of declensions as matching terms.
*/
readonly ignorePlurals?: boolean | readonly string[];
/**
* Removes stop (common) words from the query before executing it.
*/
readonly removeStopWords?: boolean | readonly string[];
/**
* List of supported languages with their associated language ISO code.
*
* Apply a set of natural language best practices such as ignorePlurals,
* removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts.
*/
readonly naturalLanguages?: readonly string[];
/**
* When true, each hit in the response contains an additional _rankingInfo object.
*/
readonly getRankingInfo?: boolean;
/**
* A user identifier.
* Format: alpha numeric string [a-zA-Z0-9_-]
* Length: between 1 and 64 characters.
*/
readonly userToken?: string;
/**
* Can be to enable or disable A/B tests at query time.
* Engine's default: true
*/
readonly enableABTest?: boolean;
/**
* Enable word segmentation (also called decompounding) at query time for
* compatible languages. For example, this turns the Dutch query
* "spaanplaatbehang" into "spaan plaat behang" to retrieve more relevant
* results.
*/
readonly decompoundQuery?: boolean;
/**
* The relevancy threshold to apply to search in a virtual index [0-100]. A Bigger
* value means fewer, but more relevant results, smaller value means more, but
* less relevant results.
*/
readonly relevancyStrictness?: number;
/**
* Whether this search should use Dynamic Re-Ranking.
* @link https://www.algolia.com/doc/guides/algolia-ai/re-ranking/
*
* Note: You need to turn on Dynamic Re-Ranking on your index for it to have an effect on
* your search results. You can do this through the Re-Ranking page on the dashboard.
* This parameter is only used to turn off Dynamic Re-Ranking (with false) at search time.
*/
readonly enableReRanking?: boolean;
/**
* When Dynamic Re-Ranking is enabled, only records that match these filters will be impacted by Dynamic Re-Ranking.
*/
readonly reRankingApplyFilter?:
| string
| readonly string[]
| ReadonlyArray<readonly string[] | string>
| null;
/**
* Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection.
*/
readonly queryLanguages?: readonly string[];
/**
* Enriches the API’s response with meta-information as to how the query was processed.
*/
readonly explain?: readonly string[];
};