/
SearchResponse.ts
230 lines (192 loc) · 4.87 KB
/
SearchResponse.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
import { Hit, Settings } from '.';
export type SearchResponse<TObject = {}> = {
/**
* The hits returned by the search.
*
* Hits are ordered according to the ranking or sorting of the index being queried.
*/
hits: Array<Hit<TObject>>;
/**
* Index of the current page (zero-based).
*/
page: number;
/**
* Number of hits returned (used only with offset)
*/
length?: number;
/**
* The offset of the first hit to returned.
*/
offset?: number;
/**
* Number of hits matched by the query.
*/
nbHits: number;
/**
* Subset of hits selected when relevancyStrictness is applied.
*/
nbSortedHits?: number;
/**
* Number of pages returned.
*
* Calculation is based on the total number of hits (nbHits) divided by the
* number of hits per page (hitsPerPage), rounded up to the nearest integer.
*/
nbPages: number;
/**
* Maximum number of hits returned per page.
*/
hitsPerPage: number;
/**
* Time the server took to process the request, in milliseconds. This does not include network time.
*/
processingTimeMS: number;
/**
* Whether the nbHits is exhaustive (true) or approximate (false).
*
* An approximation is done when the query takes more than 50ms to be
* processed (this can happen when using complex filters on millions on records).
*/
exhaustiveNbHits: boolean;
/**
* Whether the facet count is exhaustive (true) or approximate (false).
*/
exhaustiveFacetsCount?: boolean;
/**
* A mapping of each facet name to the corresponding facet counts.
*/
facets?: Record<string, Record<string, number>>;
/**
* Statistics for numerical facets.
*/
facets_stats?: Record<
string,
{
/**
* The minimum value in the result set.
*/
min: number;
/**
* The maximum value in the result set.
*/
max: number;
/**
* The average facet value in the result set.
*/
avg: number;
/**
* The sum of all values in the result set.
*/
sum: number;
}
>;
/**
* The query used to search. Accepts every character, and every character entered will be used in the search.
*
* An empty query can be used to fetch all records.
*/
query: string;
/**
* A markup text indicating which parts of the original query have been removed in order to retrieve a non-empty result set.
*/
queryAfterRemoval?: string;
/**
* A url-encoded string of all search parameters.
*/
params: string;
/**
* Unique identifier of the search query, to be sent in Insights methods. This identifier links events back to the search query it represents.
*
* Returned only if clickAnalytics is true.
*/
queryID?: string;
/**
* Used to return warnings about the query.
*/
message?: string;
/**
* The computed geo location.
*
* Format: "lat,lng", where the latitude and longitude are expressed as decimal floating point number.
*/
aroundLatLng?: string;
/**
* The automatically computed radius.
*/
automaticRadius?: string;
/**
* Actual host name of the server that processed the request.
*
* Our DNS supports automatic failover and load balancing, so this may differ from the host name used in the request.
*/
serverUsed?: string;
/**
* Index name used for the query.
*/
index?: string;
/**
* Index name used for the query. In case of AB test, the index targetted isn’t always the index used by the query.
*/
indexUsed?: string;
/**
* In case of AB test, reports the variant ID used. The variant ID is the position in the array of variants (starting at 1).
*/
abTestVariantID?: number;
/**
* The query string that will be searched, after normalization.
*/
parsedQuery?: string;
/**
* Custom user data.
*/
userData?: any;
/**
* Rules applied to the query.
*/
appliedRules?: Array<Record<string, any>>;
/**
* The explanation of the decompounding at query time.
*/
explain?: {
/**
* The explain query match.
*/
match: {
/**
* The explain query match alternatives.
*/
alternatives: Array<{
/**
* The alternative type.
*/
types: string[];
/**
* The list of alternative words.
*/
words: string[];
/**
* The number of typos.
*/
typos: number;
/**
* The offset.
*/
offset: number;
/**
* The length.
*/
length: number;
}>;
};
/**
* Query parameter reporting. Parameters are reported
* as a JSON object with one field per parameter.
*/
params?: Record<string, any>;
};
/**
* The relevancy threshold applied to search in a virtual index.
*/
appliedRelevancyStrictness?: number;
renderingContent?: Settings['renderingContent'];
};