You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 31, 2022. It is now read-only.
@@ -221,7 +222,7 @@ index.searchAsync(new Query("jim"), new CompletionHandler() {
221
222
222
223
To perform a search, you only need to initialize the index and perform a call to the search function.
223
224
224
-
The search query allows only to retrieve 1000 hits, if you need to retrieve more than 1000 hits for seo, you can use [Backup / Retrieve all index content](#backup--export-an-index)
225
+
The search query allows only to retrieve 1000 hits. If you need to retrieve more than 1000 hits (e.g. for SEO), you can use [Backup / Retrieve all index content](#backup--export-an-index).
225
226
226
227
```java
227
228
Index index = client.initIndex("contacts");
@@ -237,6 +238,10 @@ index.searchAsync(query, new CompletionHandler() {
237
238
238
239
```
239
240
241
+
### Search Response Format
242
+
243
+
#### Sample
244
+
240
245
The server response will look like:
241
246
242
247
```json
@@ -272,7 +277,110 @@ The server response will look like:
272
277
}
273
278
```
274
279
275
-
You can use the following optional arguments:
280
+
#### Fields
281
+
282
+
-`hits` (array): The hits returned by the search, sorted according to the ranking formula.
283
+
284
+
Hits are made of the JSON objects that you stored in the index; therefore, they are mostly schema-less. However, Algolia does enrich them with a few additional fields:
285
+
286
+
-`_highlightResult` (object, optional): Highlighted attributes. *Note: Only returned when [`attributesToHighlight`](#attributestohighlight) is non-empty.*
287
+
288
+
- `${attribute_name}` (object): Highlighting for one attribute.
289
+
290
+
- `value` (string): Markup text with occurrences highlighted. The tags used for highlighting are specified via [`highlightPreTag`](#highlightpretag) and [`highlightPostTag`](#highlightposttag).
291
+
292
+
- `matchLevel` (string, enum) = {`none` | `partial` | `full`}: Indicates how well the attribute matched the search query.
293
+
294
+
- `matchedWords` (array): List of words *from the query* that matched the object.
295
+
296
+
- `fullyHighlighted` (boolean): Whether the entire attribute value is highlighted.
297
+
298
+
-`_snippetResult` (object, optional): Snippeted attributes. *Note: Only returned when [`attributesToSnippet`](#attributestosnippet) is non-empty.*
299
+
300
+
-`${attribute_name}` (object): Snippeting for the corresponding attribute.
301
+
302
+
- `value` (string): Markup text with occurrences highlighted and optional ellipsis indicators. The tags used for highlighting are specified via [`highlightPreTag`](#highlightpretag) and [`highlightPostTag`](#highlightposttag). The text used to indicate ellipsis is specified via [`snippetEllipsisText`](#snippetellipsistext).
303
+
304
+
- `matchLevel` (string, enum) = {`none` | `partial` | `full`}: Indicates how well the attribute matched the search query.
305
+
306
+
-`_rankingInfo` (object, optional): Ranking information. *Note: Only returned when [`getRankingInfo`](#getrankinginfo) is `true`.*
307
+
308
+
-`nbTypos` (integer): Number of typos encountered when matching the record. Corresponds to the `typos` ranking criterion in the ranking formula.
309
+
310
+
-`firstMatchedWord` (integer): Position of the most important matched attribute in the attributes to index list. Corresponds to the `attribute` ranking criterion in the ranking formula.
311
+
312
+
-`proximityDistance` (integer): When the query contains more than one word, the sum of the distances between matched words. Corresponds to the `proximity` criterion in the ranking formula.
313
+
314
+
-`userScore` (integer): Custom ranking for the object, expressed as a single numerical value. Conceptually, it's what the position of the object would be in the list of all objects sorted by custom ranking. Corresponds to the `custom` criterion in the ranking formula.
315
+
316
+
-`geoDistance` (integer): Distance between the geo location in the search query and the best matching geo location in the record, divided by the geo precision.
317
+
318
+
-`geoPrecision` (integer): Precision used when computed the geo distance, in meters. All distances will be floored to a multiple of this precision.
319
+
320
+
-`nbExactWords` (integer): Number of exactly matched words. If `alternativeAsExact` is set, it may include plurals and/or synonyms.
321
+
322
+
-`words` (integer): Number of matched words, including prefixes and typos.
323
+
324
+
-`filters` (integer): *This field is reserved for advanced usage.* It will be zero in most cases.
325
+
326
+
-`_distinctSeqID` (integer): *Note: Only returned when [`distinct`](#distinct) is non-zero.* When two consecutive results have the same value for the attribute used for "distinct", this field is used to distinguish between them.
327
+
328
+
-`nbHits` (integer): Number of hits that the search query matched.
329
+
330
+
-`page` (integer): Index of the current page (zero-based). See the [`page`](#page) search parameter.
331
+
332
+
-`hitsPerPage` (integer): Maximum number of hits returned per page. See the [`hitsPerPage`](#hitsperpage) search parameter.
333
+
334
+
-`nbPages` (integer): Number of pages corresponding to the number of hits. Basically, `ceil(nbHits / hitsPerPage)`.
335
+
336
+
-`processingTimeMS` (integer): Time that the server took to process the request, in milliseconds. *Note: This does not include network time.*
337
+
338
+
-`query` (string): An echo of the query text. See the [`query`](#query) search parameter.
339
+
340
+
-`queryAfterRemoval` (string, optional): *Note: Only returned when [`removeWordsIfNoResults`](#removewordsifnoresults) is set.* A markup text indicating which parts of the original query have been removed in order to retrieve a non-empty result set. The removed parts are surrounded by `<em>` tags.
341
+
342
+
-`params` (string, URL-encoded): An echo of all search parameters.
343
+
344
+
-`message` (string, optional): Used to return warnings about the query.
345
+
346
+
-`aroundLatLng` (string, optional): *Note: Only returned when [`aroundLatLngViaIP`](#aroundlatlngviaip) is set.* The computed geo location. **Warning: for legacy reasons, this parameter is a string and not an object.** Format: `${lat},${lng}`, where the latitude and longitude are expressed as decimal floating point numbers.
347
+
348
+
-`automaticRadius` (integer, optional): *Note: Only returned for geo queries without an explicitly specified radius (see `aroundRadius`).* The automatically computed radius. **Warning: for legacy reasons, this parameter is a string and not an integer.**
349
+
350
+
When [`getRankingInfo`](#getrankinginfo) is set to `true`, the following additional fields are returned:
351
+
352
+
-`serverUsed` (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.)
353
+
354
+
-`parsedQuery` (string): The query string that will be searched, after normalization.
355
+
356
+
-`timeoutCounts` (boolean): Whether a timeout was hit when computing the facet counts. When `true`, the counts will be interpolated (i.e. approximate). See also `exhaustiveFacetsCount`.
357
+
358
+
-`timeoutHits` (boolean): Whether a timeout was hit when retrieving the hits. When true, some results may be missing.
359
+
360
+
... and ranking information is also added to each of the hits (see above).
361
+
362
+
When [`facets`](#facets) is non-empty, the following additional fields are returned:
363
+
364
+
-`facets` (object): Maps each facet name to the corresponding facet counts:
365
+
366
+
-`${facet_name}` (object): Facet counts for the corresponding facet name:
367
+
368
+
- `${facet_value}` (integer): Count for this facet value.
369
+
370
+
-`facets_stats` (object, optional): *Note: Only returned when at least one of the returned facets contains numerical values.* Statistics for numerical facets:
371
+
372
+
-`${facet_name}` (object): The statistics for a given facet:
373
+
374
+
- `min` (integer | float): The minimum value in the result set.
375
+
376
+
- `max` (integer | float): The maximum value in the result set.
377
+
378
+
- `avg` (integer | float): The average facet value in the result set.
379
+
380
+
- `sum` (integer | float): The sum of all values in the result set.
381
+
382
+
-`exhaustiveFacetsCount` (boolean): Whether the counts are exhaustive (`true`) or approximate (`false`). *Note: When using [`distinct`](#distinct), the facet counts cannot be exhaustive.*
383
+
276
384
277
385
### Search Parameters
278
386
@@ -328,7 +436,7 @@ Parameters that can also be used in a setSettings also have the `indexing` [scop
- `cursor` (string, optional):A cursor to retrieve the next chunk of data. If absent, it means that the end of the index has been reached.
1882
+
1883
+
- `query` (string):Query text used to filter the results.
1884
+
1885
+
- `params` (string, URL-encoded):Search parameters used to filter the results.
1886
+
1887
+
- `processingTimeMS` (integer):Time that the server took to process the request, in milliseconds. *Note:This does not include network time.*
1888
+
1889
+
The following fields are provided for convenience purposes, and **only when the browse is not filtered**:
1890
+
1891
+
- `nbHits` (integer):Number of objects in the index.
1892
+
1893
+
- `page` (integer):Index of the current page (zero-based).
1894
+
1895
+
- `hitsPerPage` (integer):Maximum number of hits returned per page.
1896
+
1897
+
- `nbPages` (integer):Number of pages corresponding to the number of hits. Basically, `ceil(nbHits / hitsPerPage)`.
1898
+
1899
+
1900
+
#### Example
1752
1901
1753
1902
Using the low-level methods:
1754
1903
@@ -1810,12 +1959,23 @@ client.multipleQueriesAsync(queries, new CompletionHandler() {
1810
1959
});
1811
1960
```
1812
1961
1813
-
The resulting JSON answer contains a ```results``` array storing the underlying queries answers. The answers order is the same than the requests order.
1814
-
1815
1962
You can specify a `strategy` parameter to optimize your multiple queries:
1816
1963
- `none`:Execute the sequence of queries until the end.
1817
1964
- `stopIfEnoughMatches`:Execute the sequence of queries until the number of hits is reached by the sum of hits.
1818
1965
1966
+
#### Response
1967
+
1968
+
The resulting JSON contains the following fields:
1969
+
1970
+
- `results` (array):The results for each request, in the order they were submitted. The contents are the same as in [Search in an index](#search-in-an-index---searchasync).
1971
+
1972
+
Each result also includes the following additional fields:
1973
+
1974
+
- `index` (string):The name of the targeted index.
1975
+
1976
+
- `processed` (boolean, optional):*Note:Only returned when `strategy` is `stopIfEnoughmatches`.*Whether the query was processed.
0 commit comments