Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit bbbee01

Browse files
author
maxiloc
authored
Merge pull request #120 from algoliareadmebot/master
docs(README): automatic update
2 parents 9c01815 + af42035 commit bbbee01

File tree

1 file changed

+169
-9
lines changed

1 file changed

+169
-9
lines changed

README.md

Lines changed: 169 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Check our [online guides](https://www.algolia.com/doc):
107107

108108

109109

110+
110111
## Getting Started
111112

112113
### Install
@@ -221,7 +222,7 @@ index.searchAsync(new Query("jim"), new CompletionHandler() {
221222

222223
To perform a search, you only need to initialize the index and perform a call to the search function.
223224

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).
225226

226227
```java
227228
Index index = client.initIndex("contacts");
@@ -237,6 +238,10 @@ index.searchAsync(query, new CompletionHandler() {
237238

238239
```
239240

241+
### Search Response Format
242+
243+
#### Sample
244+
240245
The server response will look like:
241246

242247
```json
@@ -272,7 +277,110 @@ The server response will look like:
272277
}
273278
```
274279

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+
276384

277385
### Search Parameters
278386

@@ -328,7 +436,7 @@ Parameters that can also be used in a setSettings also have the `indexing` [scop
328436

329437
**Advanced**
330438
- [distinct](#distinct) `settings`, `search`
331-
- [rankingInfo](#rankinginfo) `search`
439+
- [getRankingInfo](#getrankinginfo) `search`
332440
- [numericFilters (deprecated)](#numericfilters-deprecated) `search`
333441
- [tagFilters (deprecated)](#tagfilters-deprecated) `search`
334442
- [facetFilters (deprecated)](#facetfilters-deprecated) `search`
@@ -612,7 +720,7 @@ index.waitTask(setSettingsResult.getString("taskID"));
612720
Here is the list of parameters you can use with the set settings method (`indexing` [scope](#scope))
613721
614722
615-
Parameters that can be override at search time also have the `indexing` [scope](#scope)
723+
Parameters that can be overridden at search time also have the `search` [scope](#scope)
616724
617725
**Attributes**
618726
- [attributesToIndex](#attributestoindex) `settings`
@@ -749,7 +857,7 @@ They are three scopes:
749857
**Advanced**
750858
- [attributeForDistinct](#attributefordistinct) `settings`
751859
- [distinct](#distinct) `settings`, `search`
752-
- [rankingInfo](#rankinginfo) `search`
860+
- [getRankingInfo](#getrankinginfo) `search`
753861
- [numericAttributesToIndex](#numericattributestoindex) `settings`
754862
- [allowCompressionOfIntegerArray](#allowcompressionofintegerarray) `settings`
755863
- [numericFilters (deprecated)](#numericfilters-deprecated) `search`
@@ -1465,7 +1573,7 @@ To get a full understanding of how `Distinct` works,
14651573
you can have a look at our [guide on distinct](https://www.algolia.com/doc/search/distinct).
14661574
14671575
1468-
#### rankingInfo
1576+
#### getRankingInfo
14691577
14701578
- scope: `search`
14711579
- type: `boolean`
@@ -1748,7 +1856,48 @@ You can specify custom parameters (like `page` or `hitsPerPage`) on your first
17481856
`browse` call, and these parameters will then be included in the `cursor`. Note
17491857
that it is not possible to access records beyond the 1,000th on the first call.
17501858

1751-
Example:
1859+
#### Response Format
1860+
1861+
##### Sample
1862+
1863+
```json
1864+
{
1865+
"hits": [
1866+
{
1867+
"firstname": "Jimmie",
1868+
"lastname": "Barninger",
1869+
"objectID": "433"
1870+
}
1871+
],
1872+
"processingTimeMS": 7,
1873+
"query": "",
1874+
"params": "filters=level%3D20",
1875+
"cursor": "ARJmaWx0ZXJzPWxldmVsJTNEMjABARoGODA4OTIzvwgAgICAgICAgICAAQ=="
1876+
}
1877+
```
1878+
1879+
##### Fields
1880+
1881+
- `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
17521901

17531902
Using the low-level methods:
17541903

@@ -1810,12 +1959,23 @@ client.multipleQueriesAsync(queries, new CompletionHandler() {
18101959
});
18111960
```
18121961

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-
18151962
You can specify a `strategy` parameter to optimize your multiple queries:
18161963
- `none`: Execute the sequence of queries until the end.
18171964
- `stopIfEnoughMatches`: Execute the sequence of queries until the number of hits is reached by the sum of hits.
18181965

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.
1977+
1978+
18191979

18201980
### REST API
18211981

0 commit comments

Comments
 (0)