algoliasearch 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -5
- data/ChangeLog +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +1648 -1587
- data/algoliasearch.gemspec +3 -3
- data/lib/algolia/client.rb +9 -18
- data/lib/algolia/version.rb +1 -1
- data/lib/algoliasearch.rb +8 -1
- data/spec/client_spec.rb +25 -17
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a37e65bca2bf7c296add2c0f0187ab5bd33eedb
|
4
|
+
data.tar.gz: 7889a0cce2a6470260c3616ca71fda9022084792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db44fe908876413039e4efb0a447f9fbf7b95a3cbd11e0401d1bb53500e13d4d6b133772bb7b589c96b4de08f178a50443f101285df47a8e917c6b21c8a8d79a
|
7
|
+
data.tar.gz: 04f539db59d6de73e6d088b19b80a2182d1f931c5649e0c6af5fc4e968bd4fc698e4a9797c88a1041e1b0dc843a0a9c599892441893645330a605a07c7bdf230
|
data/.travis.yml
CHANGED
@@ -6,13 +6,12 @@ rvm:
|
|
6
6
|
- 1.8.7
|
7
7
|
- 1.9.3
|
8
8
|
- 2.0.0
|
9
|
-
- 2.1.
|
10
|
-
- 2.2.
|
11
|
-
- 2.3.
|
9
|
+
- 2.1.10
|
10
|
+
- 2.2.5
|
11
|
+
- 2.3.1
|
12
12
|
- jruby
|
13
13
|
- rbx-2
|
14
|
-
|
15
|
-
- bundle install
|
14
|
+
cache: bundler
|
16
15
|
env:
|
17
16
|
global:
|
18
17
|
- secure: OFKp0J81VrKXfpQZWkwSfsG/knN4tr45yDAGekFy4FKcA6Ra6EqDUzcY1MVrkKq9YRUgLJRfjgqF3Ei0cm2qMo1dy5XUG/fY8upTVdQK2Nm1qfbjnh70+vnYpHidHg9pEI8QROwsM7n19QoT16j1af4UinGFE/HBiJpuXcABuLw=
|
data/ChangeLog
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
net-http-persistent (>= 2.7)
|
32
32
|
net-http-pipeline
|
33
33
|
highline (1.6.21)
|
34
|
-
httpclient (2.
|
34
|
+
httpclient (2.8.2.2)
|
35
35
|
json (1.8.3)
|
36
36
|
json (1.8.3-java)
|
37
37
|
launchy (2.4.3)
|
@@ -311,7 +311,7 @@ PLATFORMS
|
|
311
311
|
DEPENDENCIES
|
312
312
|
coveralls
|
313
313
|
highline (< 1.7.0)
|
314
|
-
httpclient (~> 2.
|
314
|
+
httpclient (~> 2.8.2)
|
315
315
|
json (>= 1.5.1)
|
316
316
|
mime-types (< 2.0)
|
317
317
|
rake
|
data/README.md
CHANGED
@@ -2,17 +2,14 @@
|
|
2
2
|
|
3
3
|
# Algolia Search API Client for Ruby
|
4
4
|
|
5
|
-
<!--/NO_HTML-->
|
6
5
|
|
7
6
|
|
8
7
|
|
9
8
|
|
10
9
|
|
11
|
-
<!--NO_HTML-->
|
12
10
|
|
13
11
|
[Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
|
14
12
|
|
15
|
-
<!--/NO_HTML-->
|
16
13
|
|
17
14
|
Our Ruby client lets you easily use the [Algolia Search API](https://www.algolia.com/doc/rest) from your backend. It wraps the [Algolia Search REST API](https://www.algolia.com/doc/rest).
|
18
15
|
|
@@ -24,51 +21,135 @@ Our Ruby client lets you easily use the [Algolia Search API](https://www.algolia
|
|
24
21
|
|
25
22
|
|
26
23
|
|
27
|
-
<!--NO_HTML-->
|
28
24
|
|
29
|
-
|
30
|
-
|
25
|
+
|
26
|
+
## Table of Contents
|
27
|
+
|
31
28
|
**Getting Started**
|
32
29
|
|
33
|
-
1. [
|
30
|
+
1. [Getting started](#getting-started)
|
34
31
|
1. [Quick Start](#quick-start)
|
35
|
-
1. [Guides & Tutorials](#guides
|
32
|
+
1. [Guides & Tutorials](#guides--tutorials)
|
36
33
|
|
37
34
|
|
38
35
|
**Commands Reference**
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
1. [
|
43
|
-
1. [
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
1. [
|
48
|
-
1. [
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
1. [
|
53
|
-
1. [
|
54
|
-
1. [
|
55
|
-
1. [
|
56
|
-
|
57
|
-
|
37
|
+
Getting started
|
38
|
+
|
39
|
+
1. [Install](#install)
|
40
|
+
1. [Init index](#init-index---init_index)
|
41
|
+
|
42
|
+
Search
|
43
|
+
|
44
|
+
1. [Search in an index](#search-in-an-index---search)
|
45
|
+
1. [Find by IDs](#find-by-ids---get_objects)
|
46
|
+
|
47
|
+
Indexing
|
48
|
+
|
49
|
+
1. [Add objects](#add-objects---add_objects)
|
50
|
+
1. [Update objects](#update-objects---save_objects)
|
51
|
+
1. [Partial update](#partial-update---partial_update_objects)
|
52
|
+
1. [Delete objects](#delete-objects---delete_objects)
|
53
|
+
|
54
|
+
Settings
|
55
|
+
|
56
|
+
1. [Get settings](#get-settings---get_settings)
|
57
|
+
1. [Set settings](#set-settings---set_settings)
|
58
|
+
|
59
|
+
Manage Indices
|
60
|
+
|
61
|
+
1. [List indices](#list-indices---list_indexes)
|
62
|
+
1. [Delete index](#delete-index---delete_index)
|
63
|
+
1. [Clear index](#clear-index---clear_index)
|
64
|
+
1. [Copy index](#copy-index---copy_index)
|
65
|
+
1. [Move index](#move-index---move_index)
|
66
|
+
|
67
|
+
Api Keys
|
68
|
+
|
69
|
+
1. [Generate key](#generate-key---generate_secured_api_key)
|
70
|
+
|
71
|
+
|
72
|
+
Synonyms
|
73
|
+
|
74
|
+
1. [Save synonym](#save-synonym---save_synonym)
|
75
|
+
1. [Batch synonyms](#batch-synonyms---batch_synonyms)
|
76
|
+
1. [Editing Synonyms](#editing-synonyms)
|
77
|
+
1. [Delete Synonyms](#delete-synonyms---delete_synonyms)
|
78
|
+
1. [Clear all synonyms](#clear-all-synonyms---clear_synonyms)
|
79
|
+
1. [Get synonym](#get-synonym---get_synonym)
|
80
|
+
1. [Search synonyms](#search-synonyms---search_synonyms)
|
81
|
+
|
82
|
+
|
83
|
+
Advanced
|
84
|
+
|
85
|
+
1. [Custom batch](#custom-batch---batch)
|
86
|
+
1. [Wait for operations](#wait-for-operations---wait_task)
|
87
|
+
1. [Multiple queries](#multiple-queries---multiple_queries)
|
88
|
+
1. [Delete by query](#delete-by-query---delete_by_query)
|
89
|
+
1. [Backup / Export an index](#backup--export-an-index---browse)
|
90
|
+
1. [List api keys](#list-api-keys---list_api_keys)
|
91
|
+
1. [Add user key](#add-user-key---add_user_key)
|
92
|
+
1. [Update user key](#update-user-key---update_user_key)
|
93
|
+
1. [Delete user key](#delete-user-key---delete_user_key)
|
94
|
+
1. [Get key permissions](#get-key-permissions---get_user_key_acl)
|
95
|
+
1. [Get Logs](#get-logs---get_logs)
|
96
|
+
|
97
|
+
|
98
|
+
Mocking
|
99
|
+
|
100
|
+
1. [Mocking](#mocking)
|
101
|
+
|
102
|
+
|
103
|
+
## Guides & Tutorials
|
104
|
+
|
105
|
+
Check our [online guides](https://www.algolia.com/doc):
|
106
|
+
|
107
|
+
* [Data Formatting](https://www.algolia.com/doc/indexing/formatting-your-data)
|
108
|
+
* [Import and Synchronize data](https://www.algolia.com/doc/indexing/import-synchronize-data/ruby)
|
109
|
+
* [Autocomplete](https://www.algolia.com/doc/search/auto-complete)
|
110
|
+
* [Instant search page](https://www.algolia.com/doc/search/instant-search)
|
111
|
+
* [Filtering and Faceting](https://www.algolia.com/doc/search/filtering-faceting)
|
112
|
+
* [Sorting](https://www.algolia.com/doc/relevance/sorting)
|
113
|
+
* [Ranking Formula](https://www.algolia.com/doc/relevance/ranking)
|
114
|
+
* [Typo-Tolerance](https://www.algolia.com/doc/relevance/typo-tolerance)
|
115
|
+
* [Geo-Search](https://www.algolia.com/doc/geo-search/geo-search-overview)
|
116
|
+
* [Security](https://www.algolia.com/doc/security/best-security-practices)
|
117
|
+
* [API-Keys](https://www.algolia.com/doc/security/api-keys)
|
118
|
+
* [REST API](https://www.algolia.com/doc/rest)
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
58
127
|
|
59
128
|
<!--/NO_HTML-->
|
60
129
|
|
61
130
|
|
62
131
|
|
63
|
-
|
64
|
-
|
65
|
-
|
132
|
+
|
133
|
+
## Getting Started
|
134
|
+
|
135
|
+
### Install
|
136
|
+
|
137
|
+
|
66
138
|
|
67
139
|
|
140
|
+
Install AlgoliaSearch using:
|
68
141
|
|
142
|
+
```bash
|
143
|
+
gem install algoliasearch
|
144
|
+
```
|
145
|
+
|
146
|
+
#### Ruby on Rails
|
147
|
+
|
148
|
+
If you're a Ruby on Rails user; you're probably looking for the [algoliasearch-rails](https://github.com/algolia/algoliasearch-rails) gem.
|
69
149
|
|
70
|
-
|
71
|
-
|
150
|
+
### Init index - `init_index`
|
151
|
+
|
152
|
+
To initialize the client, you need your **Application ID** and **API Key**. You can find both of them on [your Algolia account](https://www.algolia.com/api-keys).
|
72
153
|
|
73
154
|
```ruby
|
74
155
|
require 'rubygems'
|
@@ -78,14 +159,10 @@ Algolia.init :application_id => "YourApplicationID",
|
|
78
159
|
:api_key => "YourAPIKey"
|
79
160
|
```
|
80
161
|
|
81
|
-
### Ruby on Rails
|
82
|
-
|
83
|
-
If you're a Ruby on Rails user; you're probably looking for the [algoliasearch-rails](https://github.com/algolia/algoliasearch-rails) gem.
|
84
162
|
|
85
163
|
|
164
|
+
### Quick Start
|
86
165
|
|
87
|
-
Quick Start
|
88
|
-
-------------
|
89
166
|
|
90
167
|
|
91
168
|
In 30 seconds, this quick start tutorial will show you how to index and search objects.
|
@@ -98,6 +175,7 @@ index.add_objects(batch)
|
|
98
175
|
```
|
99
176
|
|
100
177
|
You can now search for contacts using firstname, lastname, company, etc. (even with typos):
|
178
|
+
|
101
179
|
```ruby
|
102
180
|
# search by firstname
|
103
181
|
puts index.search('jimmie').to_json
|
@@ -110,17 +188,20 @@ puts index.search('jimmie paint').to_json
|
|
110
188
|
```
|
111
189
|
|
112
190
|
Settings can be customized to tune the search behavior. For example, you can add a custom sort by number of followers to the already great built-in relevance:
|
191
|
+
|
113
192
|
```ruby
|
114
193
|
index.set_settings({"customRanking" => ["desc(followers)"]})
|
115
194
|
```
|
116
195
|
|
117
196
|
You can also configure the list of attributes you want to index by order of importance (first = most important):
|
197
|
+
|
118
198
|
```ruby
|
119
199
|
index.set_settings({"attributesToIndex" => ["lastname", "firstname", "company",
|
120
200
|
"email", "city", "address"]})
|
121
201
|
```
|
122
202
|
|
123
203
|
Since the engine is designed to suggest results as you type, you'll generally search by prefix. In this case the order of attributes is very important to decide which hit is the best:
|
204
|
+
|
124
205
|
```ruby
|
125
206
|
puts index.search('or').to_json
|
126
207
|
puts index.search('jim').to_json
|
@@ -132,7 +213,7 @@ puts index.search('jim').to_json
|
|
132
213
|
* It will offload unnecessary tasks from your servers
|
133
214
|
|
134
215
|
```html
|
135
|
-
<script src="
|
216
|
+
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
|
136
217
|
<script>
|
137
218
|
var client = algoliasearch('ApplicationID', 'apiKey');
|
138
219
|
var index = client.initIndex('indexName');
|
@@ -166,34 +247,272 @@ function searchCallback(err, content) {
|
|
166
247
|
|
167
248
|
|
168
249
|
|
169
|
-
<!--NO_HTML-->
|
170
250
|
|
171
|
-
Guides & Tutorials
|
172
|
-
================
|
173
|
-
Check our [online guides](https://www.algolia.com/doc):
|
174
|
-
* [Data Formatting](https://www.algolia.com/doc/indexing/formatting-your-data)
|
175
|
-
* [Import and Synchronize data](https://www.algolia.com/doc/indexing/import-synchronize-data/ruby)
|
176
|
-
* [Autocomplete](https://www.algolia.com/doc/search/auto-complete)
|
177
|
-
* [Instant search page](https://www.algolia.com/doc/search/instant-search)
|
178
|
-
* [Filtering and Faceting](https://www.algolia.com/doc/search/filtering-faceting)
|
179
|
-
* [Sorting](https://www.algolia.com/doc/relevance/sorting)
|
180
|
-
* [Ranking Formula](https://www.algolia.com/doc/relevance/ranking)
|
181
|
-
* [Typo-Tolerance](https://www.algolia.com/doc/relevance/typo-tolerance)
|
182
|
-
* [Geo-Search](https://www.algolia.com/doc/geo-search/geo-search-overview)
|
183
|
-
* [Security](https://www.algolia.com/doc/security/best-security-practices)
|
184
|
-
* [API-Keys](https://www.algolia.com/doc/security/api-keys)
|
185
|
-
* [REST API](https://www.algolia.com/doc/rest)
|
186
251
|
|
252
|
+
## Search
|
187
253
|
|
188
|
-
|
254
|
+
### Search in an index - `search`
|
255
|
+
|
256
|
+
|
257
|
+
**Notes:** If you are building a web application, you may be more interested in using our [JavaScript client](https://github.com/algolia/algoliasearch-client-js) to perform queries. It brings two benefits:
|
258
|
+
* Your users get a better response time by not going through your servers
|
259
|
+
* It will offload unnecessary tasks from your servers.
|
260
|
+
|
261
|
+
|
262
|
+
To perform a search, you only need to initialize the index and perform a call to the search function.
|
263
|
+
|
264
|
+
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).
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
index = Algolia::Index.new("contacts")
|
268
|
+
res = index.search("query string")
|
269
|
+
res = index.search("query string", { "attributesToRetrieve" => "firstname,lastname", "hitsPerPage" => 20})
|
270
|
+
```
|
271
|
+
|
272
|
+
### Search Response Format
|
273
|
+
|
274
|
+
#### Sample
|
275
|
+
|
276
|
+
The server response will look like:
|
277
|
+
|
278
|
+
```json
|
279
|
+
{
|
280
|
+
"hits": [
|
281
|
+
{
|
282
|
+
"firstname": "Jimmie",
|
283
|
+
"lastname": "Barninger",
|
284
|
+
"objectID": "433",
|
285
|
+
"_highlightResult": {
|
286
|
+
"firstname": {
|
287
|
+
"value": "<em>Jimmie</em>",
|
288
|
+
"matchLevel": "partial"
|
289
|
+
},
|
290
|
+
"lastname": {
|
291
|
+
"value": "Barninger",
|
292
|
+
"matchLevel": "none"
|
293
|
+
},
|
294
|
+
"company": {
|
295
|
+
"value": "California <em>Paint</em> & Wlpaper Str",
|
296
|
+
"matchLevel": "partial"
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}
|
300
|
+
],
|
301
|
+
"page": 0,
|
302
|
+
"nbHits": 1,
|
303
|
+
"nbPages": 1,
|
304
|
+
"hitsPerPage": 20,
|
305
|
+
"processingTimeMS": 1,
|
306
|
+
"query": "jimmie paint",
|
307
|
+
"params": "query=jimmie+paint&attributesToRetrieve=firstname,lastname&hitsPerPage=50"
|
308
|
+
}
|
309
|
+
```
|
310
|
+
|
311
|
+
#### Fields
|
312
|
+
|
313
|
+
- `hits` (array): The hits returned by the search, sorted according to the ranking formula.
|
314
|
+
|
315
|
+
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:
|
316
|
+
|
317
|
+
- `_highlightResult` (object, optional): Highlighted attributes. *Note: Only returned when [`attributesToHighlight`](#attributestohighlight) is non-empty.*
|
318
|
+
|
319
|
+
- `${attribute_name}` (object): Highlighting for one attribute.
|
320
|
+
|
321
|
+
- `value` (string): Markup text with occurrences highlighted. The tags used for highlighting are specified via [`highlightPreTag`](#highlightpretag) and [`highlightPostTag`](#highlightposttag).
|
322
|
+
|
323
|
+
- `matchLevel` (string, enum) = {`none` | `partial` | `full`}: Indicates how well the attribute matched the search query.
|
324
|
+
|
325
|
+
- `matchedWords` (array): List of words *from the query* that matched the object.
|
326
|
+
|
327
|
+
- `fullyHighlighted` (boolean): Whether the entire attribute value is highlighted.
|
328
|
+
|
329
|
+
- `_snippetResult` (object, optional): Snippeted attributes. *Note: Only returned when [`attributesToSnippet`](#attributestosnippet) is non-empty.*
|
330
|
+
|
331
|
+
- `${attribute_name}` (object): Snippeting for the corresponding attribute.
|
332
|
+
|
333
|
+
- `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).
|
334
|
+
|
335
|
+
- `matchLevel` (string, enum) = {`none` | `partial` | `full`}: Indicates how well the attribute matched the search query.
|
336
|
+
|
337
|
+
- `_rankingInfo` (object, optional): Ranking information. *Note: Only returned when [`getRankingInfo`](#getrankinginfo) is `true`.*
|
338
|
+
|
339
|
+
- `nbTypos` (integer): Number of typos encountered when matching the record. Corresponds to the `typos` ranking criterion in the ranking formula.
|
340
|
+
|
341
|
+
- `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.
|
342
|
+
|
343
|
+
- `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.
|
344
|
+
|
345
|
+
- `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.
|
346
|
+
|
347
|
+
- `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.
|
348
|
+
|
349
|
+
- `geoPrecision` (integer): Precision used when computed the geo distance, in meters. All distances will be floored to a multiple of this precision.
|
350
|
+
|
351
|
+
- `nbExactWords` (integer): Number of exactly matched words. If `alternativeAsExact` is set, it may include plurals and/or synonyms.
|
352
|
+
|
353
|
+
- `words` (integer): Number of matched words, including prefixes and typos.
|
354
|
+
|
355
|
+
- `filters` (integer): *This field is reserved for advanced usage.* It will be zero in most cases.
|
356
|
+
|
357
|
+
- `_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.
|
358
|
+
|
359
|
+
- `nbHits` (integer): Number of hits that the search query matched.
|
360
|
+
|
361
|
+
- `page` (integer): Index of the current page (zero-based). See the [`page`](#page) search parameter.
|
362
|
+
|
363
|
+
- `hitsPerPage` (integer): Maximum number of hits returned per page. See the [`hitsPerPage`](#hitsperpage) search parameter.
|
364
|
+
|
365
|
+
- `nbPages` (integer): Number of pages corresponding to the number of hits. Basically, `ceil(nbHits / hitsPerPage)`.
|
366
|
+
|
367
|
+
- `processingTimeMS` (integer): Time that the server took to process the request, in milliseconds. *Note: This does not include network time.*
|
368
|
+
|
369
|
+
- `query` (string): An echo of the query text. See the [`query`](#query) search parameter.
|
370
|
+
|
371
|
+
- `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.
|
372
|
+
|
373
|
+
- `params` (string, URL-encoded): An echo of all search parameters.
|
374
|
+
|
375
|
+
- `message` (string, optional): Used to return warnings about the query.
|
376
|
+
|
377
|
+
- `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.
|
378
|
+
|
379
|
+
- `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.**
|
380
|
+
|
381
|
+
When [`getRankingInfo`](#getrankinginfo) is set to `true`, the following additional fields are returned:
|
382
|
+
|
383
|
+
- `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.)
|
384
|
+
|
385
|
+
- `parsedQuery` (string): The query string that will be searched, after normalization.
|
386
|
+
|
387
|
+
- `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`.
|
388
|
+
|
389
|
+
- `timeoutHits` (boolean): Whether a timeout was hit when retrieving the hits. When true, some results may be missing.
|
390
|
+
|
391
|
+
... and ranking information is also added to each of the hits (see above).
|
392
|
+
|
393
|
+
When [`facets`](#facets) is non-empty, the following additional fields are returned:
|
394
|
+
|
395
|
+
- `facets` (object): Maps each facet name to the corresponding facet counts:
|
396
|
+
|
397
|
+
- `${facet_name}` (object): Facet counts for the corresponding facet name:
|
398
|
+
|
399
|
+
- `${facet_value}` (integer): Count for this facet value.
|
400
|
+
|
401
|
+
- `facets_stats` (object, optional): *Note: Only returned when at least one of the returned facets contains numerical values.* Statistics for numerical facets:
|
402
|
+
|
403
|
+
- `${facet_name}` (object): The statistics for a given facet:
|
404
|
+
|
405
|
+
- `min` (integer | float): The minimum value in the result set.
|
406
|
+
|
407
|
+
- `max` (integer | float): The maximum value in the result set.
|
408
|
+
|
409
|
+
- `avg` (integer | float): The average facet value in the result set.
|
410
|
+
|
411
|
+
- `sum` (integer | float): The sum of all values in the result set.
|
412
|
+
|
413
|
+
- `exhaustiveFacetsCount` (boolean): Whether the counts are exhaustive (`true`) or approximate (`false`). *Note: When using [`distinct`](#distinct), the facet counts cannot be exhaustive.*
|
414
|
+
|
415
|
+
|
416
|
+
### Search Parameters
|
417
|
+
|
418
|
+
<!--PARAMETERS_LINK-->
|
419
|
+
Here is the list of parameters you can use with the search method (`search` [scope](#scope)):
|
420
|
+
Parameters that can also be used in a setSettings also have the `indexing` [scope](#scope)
|
421
|
+
|
422
|
+
**Search**
|
423
|
+
|
424
|
+
- [query](#query) `search`
|
425
|
+
|
426
|
+
**Attributes**
|
189
427
|
|
428
|
+
- [attributesToRetrieve](#attributestoretrieve) `settings`, `search`
|
190
429
|
|
430
|
+
**Filtering / Faceting**
|
191
431
|
|
432
|
+
- [filters](#filters) `search`
|
433
|
+
- [facets](#facets) `search`
|
434
|
+
- [maxValuesPerFacet](#maxvaluesperfacet) `settings`, `search`
|
192
435
|
|
436
|
+
**Highlighting / Snippeting**
|
193
437
|
|
438
|
+
- [attributesToHighlight](#attributestohighlight) `settings`, `search`
|
439
|
+
- [attributesToSnippet](#attributestosnippet) `settings`, `search`
|
440
|
+
- [highlightPreTag](#highlightpretag) `settings`, `search`
|
441
|
+
- [highlightPostTag](#highlightposttag) `settings`, `search`
|
442
|
+
- [snippetEllipsisText](#snippetellipsistext) `settings`, `search`
|
194
443
|
|
195
|
-
|
196
|
-
|
444
|
+
**Pagination**
|
445
|
+
|
446
|
+
- [page](#page) `search`
|
447
|
+
- [hitsPerPage](#hitsperpage) `settings`, `search`
|
448
|
+
|
449
|
+
**Typos**
|
450
|
+
|
451
|
+
- [minWordSizefor1Typo](#minwordsizefor1typo) `settings`, `search`
|
452
|
+
- [minWordSizefor2Typos](#minwordsizefor2typos) `settings`, `search`
|
453
|
+
- [typoTolerance](#typotolerance) `settings`, `search`
|
454
|
+
- [allowTyposOnNumericTokens](#allowtyposonnumerictokens) `settings`, `search`
|
455
|
+
- [ignorePlurals](#ignoreplurals) `settings`, `search`
|
456
|
+
- [disableTypoToleranceOnAttributes](#disabletypotoleranceonattributes) `settings`, `search`
|
457
|
+
|
458
|
+
**Geo-Search**
|
459
|
+
|
460
|
+
- [aroundLatLng](#aroundlatlng) `search`
|
461
|
+
- [aroundLatLngViaIP](#aroundlatlngviaip) `search`
|
462
|
+
- [aroundRadius](#aroundradius) `search`
|
463
|
+
- [aroundPrecision](#aroundprecision) `search`
|
464
|
+
- [minimumAroundRadius](#minimumaroundradius) `search`
|
465
|
+
- [insideBoundingBox](#insideboundingbox) `search`
|
466
|
+
- [insidePolygon](#insidepolygon) `search`
|
467
|
+
|
468
|
+
**Query Strategy**
|
469
|
+
|
470
|
+
- [queryType](#querytype) `settings`, `search`
|
471
|
+
- [removeWordsIfNoResults](#removewordsifnoresults) `settings`, `search`
|
472
|
+
- [advancedSyntax](#advancedsyntax) `settings`, `search`
|
473
|
+
- [optionalWords](#optionalwords) `settings`, `search`
|
474
|
+
- [removeStopWords](#removestopwords) `settings`, `search`
|
475
|
+
- [exactOnSingleWordQuery](#exactonsinglewordquery) `settings`, `search`
|
476
|
+
- [alternativesAsExact](#alternativesasexact) `settings`, `search`
|
477
|
+
|
478
|
+
**Advanced**
|
479
|
+
|
480
|
+
- [distinct](#distinct) `settings`, `search`
|
481
|
+
- [getRankingInfo](#getrankinginfo) `search`
|
482
|
+
- [numericFilters (deprecated)](#numericfilters-deprecated) `search`
|
483
|
+
- [tagFilters (deprecated)](#tagfilters-deprecated) `search`
|
484
|
+
- [facetFilters (deprecated)](#facetfilters-deprecated) `search`
|
485
|
+
- [analytics](#analytics) `search`
|
486
|
+
|
487
|
+
<!--/PARAMETERS_LINK-->
|
488
|
+
|
489
|
+
### Find by IDs - `get_objects`
|
490
|
+
|
491
|
+
You can easily retrieve an object using its `objectID` and optionally specify a comma separated list of attributes you want:
|
492
|
+
|
493
|
+
```ruby
|
494
|
+
# Retrieves all attributes
|
495
|
+
index.get_object("myID")
|
496
|
+
# Retrieves firstname and lastname attributes
|
497
|
+
res = index.get_object("myID", "firstname,lastname")
|
498
|
+
# Retrieves only the firstname attribute
|
499
|
+
res = index.get_object("myID", "firstname")
|
500
|
+
```
|
501
|
+
|
502
|
+
You can also retrieve a set of objects:
|
503
|
+
|
504
|
+
```ruby
|
505
|
+
res = index.get_objects(["myID", "myID2"])
|
506
|
+
```
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
## Indexing
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
### Add objects - `add_objects`
|
197
516
|
|
198
517
|
Each entry in an index has a unique identifier called `objectID`. There are two ways to add an entry to the index:
|
199
518
|
|
@@ -219,8 +538,8 @@ res = index.add_object({"firstname" => "Jimmie",
|
|
219
538
|
puts "ObjectID=" + res["objectID"]
|
220
539
|
```
|
221
540
|
|
222
|
-
|
223
|
-
|
541
|
+
|
542
|
+
### Update objects - `save_objects`
|
224
543
|
|
225
544
|
You have three options when updating an existing object:
|
226
545
|
|
@@ -237,6 +556,8 @@ index.save_object({"firstname" => "Jimmie",
|
|
237
556
|
"objectID" => "myID"})
|
238
557
|
```
|
239
558
|
|
559
|
+
### Partial update - `partial_update_objects`
|
560
|
+
|
240
561
|
You have many ways to update an object's attributes:
|
241
562
|
|
242
563
|
1. Set the attribute value
|
@@ -294,1726 +615,1442 @@ index.partial_update_object({"price" => {"value" => 42, "_operation" => "Decreme
|
|
294
615
|
Note: Here we are decrementing the value by `42`. To decrement just by one, put
|
295
616
|
`value:1`.
|
296
617
|
|
297
|
-
Search
|
298
|
-
==================
|
299
618
|
|
619
|
+
### Delete objects - `delete_objects`
|
300
620
|
|
301
|
-
|
302
|
-
|
303
|
-
|
621
|
+
You can delete an object using its `objectID`:
|
622
|
+
|
623
|
+
```ruby
|
624
|
+
index.delete_object("myID")
|
625
|
+
```
|
304
626
|
|
627
|
+
### Delete by query - `delete_by_query`
|
628
|
+
|
629
|
+
You can delete all objects matching a single query with the following code. Internally, the API client performs the query, deletes all matching hits, and waits until the deletions have been applied.
|
305
630
|
|
306
|
-
To perform a search, you only need to initialize the index and perform a call to the search function.
|
307
631
|
|
308
|
-
|
632
|
+
Take your precautions when using this method. Calling it with an empty query will result in cleaning the index of all its records.
|
309
633
|
|
310
634
|
```ruby
|
311
|
-
|
312
|
-
|
313
|
-
res = index.search("query string", { "attributesToRetrieve" => "firstname,lastname", "hitsPerPage" => 20})
|
635
|
+
params = {}
|
636
|
+
index.delete_by_query("John", params)
|
314
637
|
```
|
315
638
|
|
316
|
-
|
639
|
+
### Wait for operations - `wait_task`
|
317
640
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
},
|
334
|
-
"company": {
|
335
|
-
"value": "California <em>Paint</em> & Wlpaper Str",
|
336
|
-
"matchLevel": "partial"
|
337
|
-
}
|
338
|
-
}
|
339
|
-
}
|
340
|
-
],
|
341
|
-
"page": 0,
|
342
|
-
"nbHits": 1,
|
343
|
-
"nbPages": 1,
|
344
|
-
"hitsPerPage": 20,
|
345
|
-
"processingTimeMS": 1,
|
346
|
-
"query": "jimmie paint",
|
347
|
-
"params": "query=jimmie+paint&attributesToRetrieve=firstname,lastname&hitsPerPage=50"
|
348
|
-
}
|
641
|
+
All write operations in Algolia are asynchronous by design.
|
642
|
+
|
643
|
+
It means that when you add or update an object to your index, our servers will
|
644
|
+
reply to your request with a `taskID` as soon as they understood the write
|
645
|
+
operation.
|
646
|
+
|
647
|
+
The actual insert and indexing will be done after replying to your code.
|
648
|
+
|
649
|
+
You can wait for a task to complete using the same method with a `!`.
|
650
|
+
|
651
|
+
For example, to wait for indexing of a new object:
|
652
|
+
|
653
|
+
```ruby
|
654
|
+
res = index.add_object!({"firstname" => "Jimmie",
|
655
|
+
"lastname" => "Barninger"})
|
349
656
|
```
|
350
657
|
|
351
|
-
|
658
|
+
If you want to ensure multiple objects have been indexed, you only need to check
|
659
|
+
the biggest `taskID` with `wait_task`.
|
352
660
|
|
353
|
-
## Full Text Search Parameters
|
354
|
-
<table><tbody>
|
355
661
|
|
356
|
-
|
357
|
-
<tr>
|
358
|
-
<td valign='top'>
|
359
|
-
<div class='client-readme-param-container'>
|
360
|
-
<div class='client-readme-param-container-inner'>
|
361
|
-
<div class='client-readme-param-name'><code>query</code></div>
|
362
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div></div>
|
363
|
-
</div>
|
364
|
-
</div>
|
365
|
-
</td>
|
366
|
-
<td class='client-readme-param-content'>
|
367
|
-
<p>The instant search query string, used to set the string you want to search in your index. If no query parameter is set, the textual search will match with all the objects.</p>
|
662
|
+
## Settings
|
368
663
|
|
369
|
-
</td>
|
370
|
-
</tr>
|
371
|
-
|
372
664
|
|
373
|
-
|
374
|
-
<tr>
|
375
|
-
<td valign='top'>
|
376
|
-
<div class='client-readme-param-container'>
|
377
|
-
<div class='client-readme-param-container-inner'>
|
378
|
-
<div class='client-readme-param-name'><code>queryType</code></div>
|
379
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>prefixLast</strong></em></div></div>
|
380
|
-
</div>
|
381
|
-
</div>
|
382
|
-
</td>
|
383
|
-
<td class='client-readme-param-content'>
|
384
|
-
<p>Selects how the query words are interpreted. It can be one of the following values:</p>
|
385
665
|
|
386
|
-
|
387
|
-
<li><code>prefixAll</code>: All query words are interpreted as prefixes. This option is not recommended.</li>
|
388
|
-
<li><code>prefixLast</code>: Only the last word is interpreted as a prefix (default behavior).</li>
|
389
|
-
<li><code>prefixNone</code>: No query word is interpreted as a prefix. This option is not recommended.</li>
|
390
|
-
</ul>
|
666
|
+
### Get settings - `get_settings`
|
391
667
|
|
392
|
-
|
393
|
-
</tr>
|
394
|
-
|
668
|
+
You can retrieve settings:
|
395
669
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
<div class='client-readme-param-container-inner'>
|
401
|
-
<div class='client-readme-param-name'><code>removeWordsIfNoResults</code></div>
|
402
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>none</strong></em></div></div>
|
403
|
-
</div>
|
404
|
-
</div>
|
405
|
-
</td>
|
406
|
-
<td class='client-readme-param-content'>
|
407
|
-
<p>This option is used to select a strategy in order to avoid having an empty result page. There are three different options:</p>
|
670
|
+
```ruby
|
671
|
+
res = index.get_settings
|
672
|
+
puts settings.to_json
|
673
|
+
```
|
408
674
|
|
409
|
-
|
410
|
-
<li><code>lastWords</code>: When a query does not return any results, the last word will be added as optional. The process is repeated with n-1 word, n-2 word, ... until there are results.</li>
|
411
|
-
<li><code>firstWords</code>: When a query does not return any results, the first word will be added as optional. The process is repeated with second word, third word, ... until there are results.</li>
|
412
|
-
<li><code>allOptional</code>: When a query does not return any results, a second trial will be made with all words as optional. This is equivalent to transforming the AND operand between query terms to an OR operand.</li>
|
413
|
-
<li><code>none</code>: No specific processing is done when a query does not return any results (default behavior).</li>
|
414
|
-
</ul>
|
675
|
+
### Set settings - `set_settings`
|
415
676
|
|
416
|
-
|
417
|
-
|
418
|
-
|
677
|
+
```ruby
|
678
|
+
index.set_settings({"customRanking" => ["desc(followers)"]})
|
679
|
+
```
|
419
680
|
|
420
|
-
|
421
|
-
<tr>
|
422
|
-
<td valign='top'>
|
423
|
-
<div class='client-readme-param-container'>
|
424
|
-
<div class='client-readme-param-container-inner'>
|
425
|
-
<div class='client-readme-param-name'><code>minWordSizefor1Typo</code></div>
|
426
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>number</strong></em></div><div><em>Default: <strong>4</strong></em></div></div>
|
427
|
-
</div>
|
428
|
-
</div>
|
429
|
-
</td>
|
430
|
-
<td class='client-readme-param-content'>
|
431
|
-
<p>The minimum number of characters in a query word to accept one typo in this word.<br/>Defaults to 4.</p>
|
681
|
+
**Warning**
|
432
682
|
|
433
|
-
|
434
|
-
</tr>
|
435
|
-
|
683
|
+
Performance wise, it's better to do a `set_settings` before pushing the data
|
436
684
|
|
437
|
-
|
438
|
-
<tr>
|
439
|
-
<td valign='top'>
|
440
|
-
<div class='client-readme-param-container'>
|
441
|
-
<div class='client-readme-param-container-inner'>
|
442
|
-
<div class='client-readme-param-name'><code>minWordSizefor2Typos</code></div>
|
443
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>number</strong></em></div><div><em>Default: <strong>8</strong></em></div></div>
|
444
|
-
</div>
|
445
|
-
</div>
|
446
|
-
</td>
|
447
|
-
<td class='client-readme-param-content'>
|
448
|
-
<p>The minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to 8.</p>
|
685
|
+
#### Slave settings
|
449
686
|
|
450
|
-
|
451
|
-
</tr>
|
452
|
-
|
687
|
+
You can forward all settings updates to the slaves of an index by using the `forwardToSlaves` option:
|
453
688
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
<div class='client-readme-param-container'>
|
458
|
-
<div class='client-readme-param-container-inner'>
|
459
|
-
<div class='client-readme-param-name'><code>typoTolerance</code></div>
|
460
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>true</strong></em></div></div>
|
461
|
-
</div>
|
462
|
-
</div>
|
463
|
-
</td>
|
464
|
-
<td class='client-readme-param-content'>
|
465
|
-
<p>This option allows you to control the number of typos allowed in the result set:</p>
|
689
|
+
```ruby
|
690
|
+
index.set_settings({"customRanking" => ["desc(followers)"]}, {"forwardToSlave" => true})
|
691
|
+
```
|
466
692
|
|
467
|
-
<ul>
|
468
|
-
<li><code>true</code>: The typo tolerance is enabled and all matching hits are retrieved (default behavior).</li>
|
469
|
-
<li><code>false</code>: The typo tolerance is disabled. All results with typos will be hidden.</li>
|
470
|
-
<li><code>min</code>: Only keep results with the minimum number of typos. For example, if one result matches without typos, then all results with typos will be hidden.</li>
|
471
|
-
<li><code>strict</code>: Hits matching with 2 typos are not retrieved if there are some matching without typos.</li>
|
472
|
-
</ul>
|
473
693
|
|
474
|
-
</td>
|
475
|
-
</tr>
|
476
|
-
|
477
694
|
|
478
|
-
|
479
|
-
<tr>
|
480
|
-
<td valign='top'>
|
481
|
-
<div class='client-readme-param-container'>
|
482
|
-
<div class='client-readme-param-container-inner'>
|
483
|
-
<div class='client-readme-param-name'><code>allowTyposOnNumericTokens</code></div>
|
484
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>true</strong></em></div></div>
|
485
|
-
</div>
|
486
|
-
</div>
|
487
|
-
</td>
|
488
|
-
<td class='client-readme-param-content'>
|
489
|
-
<p>If set to false, disables typo tolerance on numeric tokens (numbers). Defaults to true.</p>
|
695
|
+
### Index settings parameters
|
490
696
|
|
491
|
-
|
492
|
-
</tr>
|
493
|
-
|
697
|
+
<!--PARAMETERS_LINK-->
|
494
698
|
|
495
|
-
|
496
|
-
<tr>
|
497
|
-
<td valign='top'>
|
498
|
-
<div class='client-readme-param-container'>
|
499
|
-
<div class='client-readme-param-container-inner'>
|
500
|
-
<div class='client-readme-param-name'><code>ignorePlural</code></div>
|
501
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>false</strong></em></div></div>
|
502
|
-
</div>
|
503
|
-
</div>
|
504
|
-
</td>
|
505
|
-
<td class='client-readme-param-content'>
|
506
|
-
<p>If set to true, plural won't be considered as a typo. For example, car and cars, or foot and feet will be considered as equivalent. Defaults to false.</p>
|
699
|
+
Here is the list of parameters you can use with the set settings method (`indexing` [scope](#scope))
|
507
700
|
|
508
|
-
</td>
|
509
|
-
</tr>
|
510
|
-
|
511
701
|
|
512
|
-
|
513
|
-
<tr>
|
514
|
-
<td valign='top'>
|
515
|
-
<div class='client-readme-param-container'>
|
516
|
-
<div class='client-readme-param-container-inner'>
|
517
|
-
<div class='client-readme-param-name'><code>disableTypoToleranceOnAttributes</code></div>
|
518
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>[]</strong></em></div></div>
|
519
|
-
</div>
|
520
|
-
</div>
|
521
|
-
</td>
|
522
|
-
<td class='client-readme-param-content'>
|
523
|
-
<p>List of attributes on which you want to disable typo tolerance (must be a subset of the <code>attributesToIndex</code> index setting). Attributes are separated with a comma such as <code>"name,address"</code>. You can also use JSON string array encoding such as <code>encodeURIComponent("[\"name\",\"address\"]")</code>. By default, this list is empty.</p>
|
702
|
+
Parameters that can be overridden at search time also have the `search` [scope](#scope)
|
524
703
|
|
525
|
-
|
526
|
-
</tr>
|
527
|
-
|
704
|
+
**Attributes**
|
528
705
|
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
<div class='client-readme-param-container-inner'>
|
534
|
-
<div class='client-readme-param-name'><code>restrictSearchableAttributes</code></div>
|
535
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>attributesToIndex</strong></em></div></div>
|
536
|
-
</div>
|
537
|
-
</div>
|
538
|
-
</td>
|
539
|
-
<td class='client-readme-param-content'>
|
540
|
-
<p>List of attributes you want to use for textual search (must be a subset of the <code>attributesToIndex</code> index setting). Attributes are separated with a comma such as <code>"name,address"</code>. You can also use JSON string array encoding such as <code>encodeURIComponent("[\"name\",\"address\"]")</code>. By default, all attributes specified in the <code>attributesToIndex</code> settings are used to search.</p>
|
706
|
+
- [attributesToIndex](#attributestoindex) `settings`
|
707
|
+
- [attributesForFaceting](#attributesforfaceting) `settings`
|
708
|
+
- [attributesToRetrieve](#attributestoretrieve) `settings`, `search`
|
709
|
+
- [unretrievableAttributes](#unretrievableattributes) `settings`
|
541
710
|
|
542
|
-
|
543
|
-
</tr>
|
544
|
-
|
711
|
+
**Ranking**
|
545
712
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
<div class='client-readme-param-container'>
|
550
|
-
<div class='client-readme-param-container-inner'>
|
551
|
-
<div class='client-readme-param-name'><code>removeStopWords</code></div>
|
552
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>false</strong></em></div></div>
|
553
|
-
</div>
|
554
|
-
</div>
|
555
|
-
</td>
|
556
|
-
<td class='client-readme-param-content'>
|
557
|
-
<p>Remove stop words from the query <strong>before</strong> executing it. Defaults to <code>false</code>. Use a boolean to enable/disable all 41 supported languages and a comma separated list of iso codes of the languages you want to use consider to enable the stopwords removal on a subset of them (select the one you have in your records). In most use-cases, you shouldn't need to enable this option.</p>
|
713
|
+
- [ranking](#ranking) `settings`
|
714
|
+
- [customRanking](#customranking) `settings`
|
715
|
+
- [slaves](#slaves) `settings`
|
558
716
|
|
559
|
-
|
717
|
+
**Filtering / Faceting**
|
560
718
|
|
561
|
-
|
719
|
+
- [maxValuesPerFacet](#maxvaluesperfacet) `settings`, `search`
|
562
720
|
|
563
|
-
|
564
|
-
<li><p><code>queryType=prefixLast</code> means the last query word is a prefix and it won’t be considered for stop words removal</p></li>
|
565
|
-
<li><p><code>queryType=prefixNone</code> means no query word are prefix, stop words removal will be applied on all query words</p></li>
|
566
|
-
<li><p><code>queryType=prefixAll</code> means all query terms are prefix, stop words won’t be removed</p></li>
|
567
|
-
</ul>
|
721
|
+
**Highlighting / Snippeting**
|
568
722
|
|
569
|
-
|
723
|
+
- [attributesToHighlight](#attributestohighlight) `settings`, `search`
|
724
|
+
- [attributesToSnippet](#attributestosnippet) `settings`, `search`
|
725
|
+
- [highlightPreTag](#highlightpretag) `settings`, `search`
|
726
|
+
- [highlightPostTag](#highlightposttag) `settings`, `search`
|
727
|
+
- [snippetEllipsisText](#snippetellipsistext) `settings`, `search`
|
570
728
|
|
571
|
-
|
572
|
-
</tr>
|
573
|
-
|
729
|
+
**Pagination**
|
574
730
|
|
575
|
-
|
576
|
-
<tr>
|
577
|
-
<td valign='top'>
|
578
|
-
<div class='client-readme-param-container'>
|
579
|
-
<div class='client-readme-param-container-inner'>
|
580
|
-
<div class='client-readme-param-name'><code>exactOnSingleWordQuery</code></div>
|
581
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>attribute</strong></em></div></div>
|
582
|
-
</div>
|
583
|
-
</div>
|
584
|
-
</td>
|
585
|
-
<td class='client-readme-param-content'>
|
586
|
-
<p>This parameter control how the <code>exact</code> ranking criterion is computed when the query contains one word. There is three different values:</p>
|
731
|
+
- [hitsPerPage](#hitsperpage) `settings`, `search`
|
587
732
|
|
588
|
-
|
589
|
-
<li><p><code>none</code>: no exact on single word query</p></li>
|
590
|
-
<li><p><code>word</code>: exact set to 1 if the query word is found in the record. The query word needs to have at least 3 chars and not be part of our stop words dictionary</p></li>
|
591
|
-
<li><p><code>attribute</code> (default): exact set to 1 if there is an attribute containing a string equals to the query</p></li>
|
592
|
-
</ul>
|
733
|
+
**Typos**
|
593
734
|
|
594
|
-
|
595
|
-
|
596
|
-
|
735
|
+
- [minWordSizefor1Typo](#minwordsizefor1typo) `settings`, `search`
|
736
|
+
- [minWordSizefor2Typos](#minwordsizefor2typos) `settings`, `search`
|
737
|
+
- [typoTolerance](#typotolerance) `settings`, `search`
|
738
|
+
- [allowTyposOnNumericTokens](#allowtyposonnumerictokens) `settings`, `search`
|
739
|
+
- [ignorePlurals](#ignoreplurals) `settings`, `search`
|
740
|
+
- [disableTypoToleranceOnAttributes](#disabletypotoleranceonattributes) `settings`, `search`
|
741
|
+
- [separatorsToIndex](#separatorstoindex) `settings`
|
597
742
|
|
598
|
-
|
599
|
-
<tr>
|
600
|
-
<td valign='top'>
|
601
|
-
<div class='client-readme-param-container'>
|
602
|
-
<div class='client-readme-param-container-inner'>
|
603
|
-
<div class='client-readme-param-name'><code>alternativesAsExact</code></div>
|
604
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>["ignorePlurals", "singleWordSynonym"]</strong></em></div></div>
|
605
|
-
</div>
|
606
|
-
</div>
|
607
|
-
</td>
|
608
|
-
<td class='client-readme-param-content'>
|
609
|
-
<p>Specify the list of approximation that should be considered as an exact match in the ranking formula:</p>
|
743
|
+
**Query Strategy**
|
610
744
|
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
745
|
+
- [queryType](#querytype) `settings`, `search`
|
746
|
+
- [removeWordsIfNoResults](#removewordsifnoresults) `settings`, `search`
|
747
|
+
- [advancedSyntax](#advancedsyntax) `settings`, `search`
|
748
|
+
- [optionalWords](#optionalwords) `settings`, `search`
|
749
|
+
- [removeStopWords](#removestopwords) `settings`, `search`
|
750
|
+
- [disablePrefixOnAttributes](#disableprefixonattributes) `settings`
|
751
|
+
- [disableExactOnAttributes](#disableexactonattributes) `settings`, `search`
|
752
|
+
- [exactOnSingleWordQuery](#exactonsinglewordquery) `settings`, `search`
|
753
|
+
- [alternativesAsExact](#alternativesasexact) `settings`, `search`
|
616
754
|
|
617
|
-
|
618
|
-
</tr>
|
619
|
-
|
755
|
+
**Advanced**
|
620
756
|
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>0 (false)</strong></em></div></div>
|
628
|
-
</div>
|
629
|
-
</div>
|
630
|
-
</td>
|
631
|
-
<td class='client-readme-param-content'>
|
632
|
-
<p>Enables the advanced query syntax. Defaults to 0 (false).</p>
|
757
|
+
- [attributeForDistinct](#attributefordistinct) `settings`
|
758
|
+
- [distinct](#distinct) `settings`, `search`
|
759
|
+
- [numericAttributesToIndex](#numericattributestoindex) `settings`
|
760
|
+
- [allowCompressionOfIntegerArray](#allowcompressionofintegerarray) `settings`
|
761
|
+
- [altCorrections](#altcorrections) `settings`
|
762
|
+
- [placeholders](#placeholders) `settings`
|
633
763
|
|
634
|
-
|
635
|
-
<li><strong>Phrase query</strong>: A phrase query defines a particular sequence of terms. A phrase query is built by Algolia's query parser for words surrounded by <code>"</code>. For example, <code>"search engine"</code> will retrieve records having <code>search</code> next to <code>engine</code> only. Typo tolerance is <em>disabled</em> on phrase queries.</li>
|
636
|
-
<li><strong>Prohibit operator</strong>: The prohibit operator excludes records that contain the term after the <code>-</code> symbol. For example, <code>search -engine</code> will retrieve records containing <code>search</code> but not <code>engine</code>.</li>
|
637
|
-
</ul>
|
764
|
+
<!--/PARAMETERS_LINK-->
|
638
765
|
|
639
|
-
</td>
|
640
|
-
</tr>
|
641
|
-
|
642
766
|
|
643
|
-
|
644
|
-
<tr>
|
645
|
-
<td valign='top'>
|
646
|
-
<div class='client-readme-param-container'>
|
647
|
-
<div class='client-readme-param-container-inner'>
|
648
|
-
<div class='client-readme-param-name'><code>analytics</code></div>
|
649
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>true</strong></em></div></div>
|
650
|
-
</div>
|
651
|
-
</div>
|
652
|
-
</td>
|
653
|
-
<td class='client-readme-param-content'>
|
654
|
-
<p>If set to false, this query will not be taken into account in the analytics feature. Defaults to true.</p>
|
767
|
+
## Parameters
|
655
768
|
|
656
|
-
|
657
|
-
</tr>
|
658
|
-
|
769
|
+
### Overview
|
659
770
|
|
660
|
-
|
661
|
-
<tr>
|
662
|
-
<td valign='top'>
|
663
|
-
<div class='client-readme-param-container'>
|
664
|
-
<div class='client-readme-param-container-inner'>
|
665
|
-
<div class='client-readme-param-name'><code>synonyms</code></div>
|
666
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>true</strong></em></div></div>
|
667
|
-
</div>
|
668
|
-
</div>
|
669
|
-
</td>
|
670
|
-
<td class='client-readme-param-content'>
|
671
|
-
<p>If set to false, this query will not use synonyms defined in the configuration. Defaults to true.</p>
|
771
|
+
#### Scope
|
672
772
|
|
673
|
-
|
674
|
-
|
675
|
-
|
773
|
+
Each parameter in this page has a scope. Depending on the scope, you can use the parameter within the `setSettings`
|
774
|
+
and/or the `search` method
|
676
775
|
|
677
|
-
|
678
|
-
<tr>
|
679
|
-
<td valign='top'>
|
680
|
-
<div class='client-readme-param-container'>
|
681
|
-
<div class='client-readme-param-container-inner'>
|
682
|
-
<div class='client-readme-param-name'><code>replaceSynonymsInHighlight</code></div>
|
683
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>true</strong></em></div></div>
|
684
|
-
</div>
|
685
|
-
</div>
|
686
|
-
</td>
|
687
|
-
<td class='client-readme-param-content'>
|
688
|
-
<p>If set to false, words matched via synonym expansion will not be replaced by the matched synonym in the highlight results. Defaults to true.</p>
|
776
|
+
They are three scopes:
|
689
777
|
|
690
|
-
|
691
|
-
|
692
|
-
|
778
|
+
- `settings`: The setting can only be used in the `setSettings` method
|
779
|
+
- `search`: The setting can only be used in the `search` method
|
780
|
+
- `settings` `search`: The setting can be used in the `setSettings` method and be override in the`search` method
|
693
781
|
|
694
|
-
|
695
|
-
<tr>
|
696
|
-
<td valign='top'>
|
697
|
-
<div class='client-readme-param-container'>
|
698
|
-
<div class='client-readme-param-container-inner'>
|
699
|
-
<div class='client-readme-param-name'><code>optionalWords</code></div>
|
700
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>[]</strong></em></div></div>
|
701
|
-
</div>
|
702
|
-
</div>
|
703
|
-
</td>
|
704
|
-
<td class='client-readme-param-content'>
|
705
|
-
<p>A string that contains the comma separated list of words that should be considered as optional when found in the query.</p>
|
706
782
|
|
707
|
-
|
708
|
-
</tr>
|
709
|
-
|
710
|
-
|
711
|
-
</tbody></table>
|
783
|
+
#### Parameters List
|
712
784
|
|
713
|
-
|
785
|
+
**Search**
|
714
786
|
|
715
|
-
|
787
|
+
- [query](#query) `search`
|
716
788
|
|
717
|
-
|
718
|
-
<tr>
|
719
|
-
<td valign='top'>
|
720
|
-
<div class='client-readme-param-container'>
|
721
|
-
<div class='client-readme-param-container-inner'>
|
722
|
-
<div class='client-readme-param-name'><code>page</code></div>
|
723
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer</strong></em></div><div><em>Default: <strong>0</strong></em></div></div>
|
724
|
-
</div>
|
725
|
-
</div>
|
726
|
-
</td>
|
727
|
-
<td class='client-readme-param-content'>
|
728
|
-
<p>Pagination parameter used to select the page to retrieve.<br/>Page is zero based and defaults to 0. Thus, to retrieve the 10th page you need to set <code>page=9</code>.</p>
|
789
|
+
**Attributes**
|
729
790
|
|
730
|
-
|
731
|
-
|
732
|
-
|
791
|
+
- [attributesForFaceting](#attributesforfaceting) `settings`
|
792
|
+
- [attributesToIndex](#attributestoindex) `settings`
|
793
|
+
- [attributesToRetrieve](#attributestoretrieve) `settings`, `search`
|
794
|
+
- [unretrievableAttributes](#unretrievableattributes) `settings`
|
733
795
|
|
734
|
-
|
735
|
-
<tr>
|
736
|
-
<td valign='top'>
|
737
|
-
<div class='client-readme-param-container'>
|
738
|
-
<div class='client-readme-param-container-inner'>
|
739
|
-
<div class='client-readme-param-name'><code>hitsPerPage</code></div>
|
740
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer</strong></em></div><div><em>Default: <strong>20</strong></em></div></div>
|
741
|
-
</div>
|
742
|
-
</div>
|
743
|
-
</td>
|
744
|
-
<td class='client-readme-param-content'>
|
745
|
-
<p>Pagination parameter used to select the number of hits per page. Defaults to 20.</p>
|
746
796
|
|
747
|
-
|
748
|
-
</tr>
|
749
|
-
|
797
|
+
**Ranking**
|
750
798
|
|
751
|
-
|
799
|
+
- [ranking](#ranking) `settings`
|
800
|
+
- [customRanking](#customranking) `settings`
|
801
|
+
- [slaves](#slaves) `settings`
|
752
802
|
|
803
|
+
**Filtering / Faceting**
|
753
804
|
|
754
|
-
|
755
|
-
|
756
|
-
|
805
|
+
- [filters](#filters) `search`
|
806
|
+
- [facets](#facets) `search`
|
807
|
+
- [maxValuesPerFacet](#maxvaluesperfacet) `settings`, `search`
|
757
808
|
|
758
|
-
|
759
|
-
<tr>
|
760
|
-
<td valign='top'>
|
761
|
-
<div class='client-readme-param-container'>
|
762
|
-
<div class='client-readme-param-container-inner'>
|
763
|
-
<div class='client-readme-param-name'><code>aroundLatLng</code></div>
|
764
|
-
|
765
|
-
</div>
|
766
|
-
</div>
|
767
|
-
</td>
|
768
|
-
<td class='client-readme-param-content'>
|
769
|
-
<p>Search for entries around a given latitude/longitude (specified as two floats separated by a comma).<br/>For example, <code>aroundLatLng=47.316669,5.016670</code>.</p>
|
809
|
+
**Highlighting / Snippeting**
|
770
810
|
|
771
|
-
|
811
|
+
- [attributesToHighlight](#attributestohighlight) `settings`, `search`
|
812
|
+
- [attributesToSnippet](#attributestosnippet) `settings`, `search`
|
813
|
+
- [highlightPreTag](#highlightpretag) `settings`, `search`
|
814
|
+
- [highlightPostTag](#highlightposttag) `settings`, `search`
|
815
|
+
- [snippetEllipsisText](#snippetellipsistext) `settings`, `search`
|
816
|
+
- [restrictHighlightAndSnippetArrays](#restricthighlightandsnippetarrays) `settings`, `search`
|
772
817
|
|
773
|
-
|
818
|
+
**Pagination**
|
774
819
|
|
775
|
-
|
776
|
-
|
777
|
-
|
820
|
+
- [page](#page) `search`
|
821
|
+
- [hitsPerPage](#hitsperpage) `settings`, `search`
|
778
822
|
|
779
|
-
|
823
|
+
**Typos**
|
780
824
|
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
</div>
|
790
|
-
</div>
|
791
|
-
</td>
|
792
|
-
<td class='client-readme-param-content'>
|
793
|
-
<p>Search for entries around a given latitude/longitude automatically computed from user IP address.<br/>To enable it, use <code>aroundLatLngViaIP=true</code>.</p>
|
825
|
+
- [minWordSizefor1Typo](#minwordsizefor1typo) `settings`, `search`
|
826
|
+
- [minWordSizefor2Typos](#minwordsizefor2typos) `settings`, `search`
|
827
|
+
- [typoTolerance](#typotolerance) `settings`, `search`
|
828
|
+
- [allowTyposOnNumericTokens](#allowtyposonnumerictokens) `settings`, `search`
|
829
|
+
- [ignorePlurals](#ignoreplurals) `settings`, `search`
|
830
|
+
- [disableTypoToleranceOnAttributes](#disabletypotoleranceonattributes) `settings`, `search`
|
831
|
+
- [separatorsToIndex](#separatorstoindex) `settings`
|
794
832
|
|
795
|
-
|
833
|
+
**Geo-Search**
|
796
834
|
|
797
|
-
|
835
|
+
- [aroundLatLng](#aroundlatlng) `search`
|
836
|
+
- [aroundLatLngViaIP](#aroundlatlngviaip) `search`
|
837
|
+
- [aroundRadius](#aroundradius) `search`
|
838
|
+
- [aroundPrecision](#aroundprecision) `search`
|
839
|
+
- [minimumAroundRadius](#minimumaroundradius) `search`
|
840
|
+
- [insideBoundingBox](#insideboundingbox) `search`
|
841
|
+
- [insidePolygon](#insidepolygon) `search`
|
798
842
|
|
799
|
-
|
800
|
-
</tr>
|
801
|
-
|
843
|
+
**Query Strategy**
|
802
844
|
|
803
|
-
|
845
|
+
- [queryType](#querytype) `settings`, `search`
|
846
|
+
- [removeWordsIfNoResults](#removewordsifnoresults) `settings`, `search`
|
847
|
+
- [advancedSyntax](#advancedsyntax) `settings`, `search`
|
848
|
+
- [optionalWords](#optionalwords) `settings`, `search`
|
849
|
+
- [removeStopWords](#removestopwords) `settings`, `search`
|
850
|
+
- [disablePrefixOnAttributes](#disableprefixonattributes) `settings`
|
851
|
+
- [disableExactOnAttributes](#disableexactonattributes) `settings`, `search`
|
852
|
+
- [exactOnSingleWordQuery](#exactonsinglewordquery) `settings`, `search`
|
853
|
+
- [alternativesAsExact](#alternativesasexact) `settings`, `search`
|
804
854
|
|
805
|
-
|
806
|
-
<tr>
|
807
|
-
<td valign='top'>
|
808
|
-
<div class='client-readme-param-container'>
|
809
|
-
<div class='client-readme-param-container-inner'>
|
810
|
-
<div class='client-readme-param-name'><code>insideBoundingBox</code></div>
|
811
|
-
|
812
|
-
</div>
|
813
|
-
</div>
|
814
|
-
</td>
|
815
|
-
<td class='client-readme-param-content'>
|
816
|
-
<p>Search entries inside a given area defined by the two extreme points of a rectangle (defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng).<br/>For example, <code>insideBoundingBox=47.3165,4.9665,47.3424,5.0201</code>).<br/>At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form <code>"_geoloc":{"lat":48.853409, "lng":2.348800}</code> or <code>"_geoloc":[{"lat":48.853409, "lng":2.348800},{"lat":48.547456, "lng":2.972075}]</code> if you have several geo-locations in your record). You can use several bounding boxes (OR) by passing more than 4 values. For example instead of having 4 values you can pass 8 to search inside the UNION of two bounding boxes.</p>
|
855
|
+
**Advanced**
|
817
856
|
|
818
|
-
|
819
|
-
|
820
|
-
|
857
|
+
- [attributeForDistinct](#attributefordistinct) `settings`
|
858
|
+
- [distinct](#distinct) `settings`, `search`
|
859
|
+
- [getRankingInfo](#getrankinginfo) `search`
|
860
|
+
- [numericAttributesToIndex](#numericattributestoindex) `settings`
|
861
|
+
- [allowCompressionOfIntegerArray](#allowcompressionofintegerarray) `settings`
|
862
|
+
- [numericFilters (deprecated)](#numericfilters-deprecated) `search`
|
863
|
+
- [tagFilters (deprecated)](#tagfilters-deprecated) `search`
|
864
|
+
- [facetFilters (deprecated)](#facetfilters-deprecated) `search`
|
865
|
+
- [analytics](#analytics) `search`
|
866
|
+
- [altCorrections](#altcorrections) `settings`
|
867
|
+
- [placeholders](#placeholders) `settings`
|
821
868
|
|
822
|
-
|
823
|
-
<tr>
|
824
|
-
<td valign='top'>
|
825
|
-
<div class='client-readme-param-container'>
|
826
|
-
<div class='client-readme-param-container-inner'>
|
827
|
-
<div class='client-readme-param-name'><code>insidePolygon</code></div>
|
828
|
-
|
829
|
-
</div>
|
830
|
-
</div>
|
831
|
-
</td>
|
832
|
-
<td class='client-readme-param-content'>
|
833
|
-
<p>Search entries inside a given area defined by a set of points (defined by a minimum of 6 floats: p1Lat,p1Lng,p2Lat,p2Lng,p3Lat,p3Long).<br/>For example <code>InsidePolygon=47.3165,4.9665,47.3424,5.0201,47.32,4.98</code>).<br/>At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form <code>"_geoloc":{"lat":48.853409, "lng":2.348800}</code> or <code>"_geoloc":[{"lat":48.853409, "lng":2.348800},{"lat":48.547456, "lng":2.972075}]</code> if you have several geo-locations in your record).</p>
|
869
|
+
### Search
|
834
870
|
|
835
|
-
|
836
|
-
</tr>
|
837
|
-
|
871
|
+
#### query
|
838
872
|
|
839
|
-
|
873
|
+
- scope: `search`
|
874
|
+
- type: `string`
|
875
|
+
- default: `""`
|
840
876
|
|
841
877
|
|
842
|
-
|
878
|
+
The instant search query string, used to set the string you want to search in your index. If no query parameter is set, the textual search will match with all the objects.
|
843
879
|
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
<tr>
|
848
|
-
<td valign='top'>
|
849
|
-
<div class='client-readme-param-container'>
|
850
|
-
<div class='client-readme-param-container-inner'>
|
851
|
-
<div class='client-readme-param-name'><code>attributesToRetrieve</code></div>
|
852
|
-
|
853
|
-
</div>
|
854
|
-
</div>
|
855
|
-
</td>
|
856
|
-
<td class='client-readme-param-content'>
|
857
|
-
<p>A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.</p>
|
880
|
+
### Attributes
|
858
881
|
|
859
|
-
|
882
|
+
#### attributesToIndex
|
860
883
|
|
861
|
-
|
884
|
+
- scope: `settings`
|
885
|
+
- type: `array of strings`
|
886
|
+
- default: `*`
|
862
887
|
|
863
|
-
</td>
|
864
|
-
</tr>
|
865
|
-
|
866
888
|
|
867
|
-
|
868
|
-
<tr>
|
869
|
-
<td valign='top'>
|
870
|
-
<div class='client-readme-param-container'>
|
871
|
-
<div class='client-readme-param-container-inner'>
|
872
|
-
<div class='client-readme-param-name'><code>attributesToHighlight</code></div>
|
873
|
-
|
874
|
-
</div>
|
875
|
-
</div>
|
876
|
-
</td>
|
877
|
-
<td class='client-readme-param-content'>
|
878
|
-
<p>A string that contains the list of attributes you want to highlight according to the query. Attributes are separated by commas. You can also use a string array encoding (for example <code>["name","address"]</code>). If an attribute has no match for the query, the raw value is returned. By default, all indexed attributes are highlighted (as long as they are strings). You can use <code>*</code> if you want to highlight all attributes. A matchLevel is returned for each highlighted attribute and can contain:</p>
|
889
|
+
The list of attributes you want index (i.e. to make searchable).
|
879
890
|
|
880
|
-
|
881
|
-
|
882
|
-
<li><strong>partial</strong>: If only some of the query terms were found.</li>
|
883
|
-
<li><strong>none</strong>: If none of the query terms were found.</li>
|
884
|
-
</ul>
|
891
|
+
If set to null, all textual and numerical attributes of your objects are indexed.
|
892
|
+
Make sure you updated this setting to get optimal results.
|
885
893
|
|
886
|
-
|
887
|
-
</tr>
|
888
|
-
|
894
|
+
This parameter has two important uses:
|
889
895
|
|
890
|
-
|
891
|
-
<tr>
|
892
|
-
<td valign='top'>
|
893
|
-
<div class='client-readme-param-container'>
|
894
|
-
<div class='client-readme-param-container-inner'>
|
895
|
-
<div class='client-readme-param-name'><code>attributesToSnippet</code></div>
|
896
|
-
|
897
|
-
</div>
|
898
|
-
</div>
|
899
|
-
</td>
|
900
|
-
<td class='client-readme-param-content'>
|
901
|
-
<p>A string that contains the list of attributes to snippet alongside the number of words to return (syntax is <code>attributeName:nbWords</code>). Attributes are separated by commas (Example: <code>attributesToSnippet=name:10,content:10</code>).</p>
|
896
|
+
1. **Limit the attributes to index.** For example, if you store the URL of a picture, you want to store it and be able to retrieve it, but you probably don't want to search in the URL.
|
902
897
|
|
903
|
-
|
898
|
+
2. **Control part of the ranking.** The contents of the `attributesToIndex` parameter impacts ranking in two complementary ways:
|
904
899
|
|
905
|
-
|
906
|
-
</tr>
|
907
|
-
|
900
|
+
First, the order in which attributes are listed defines their ranking priority: matches in attributes at the beginning of the list will be considered more important than matches in attributes further down the list. To assign the same priority to several attributes, pass them within the same string, separated by commas. For example, by specifying `["title,"alternative_title", "text"]`, `title` and `alternative_title` will have the same priority, but a higher priority than `text`.
|
908
901
|
|
909
|
-
|
910
|
-
<tr>
|
911
|
-
<td valign='top'>
|
912
|
-
<div class='client-readme-param-container'>
|
913
|
-
<div class='client-readme-param-container-inner'>
|
914
|
-
<div class='client-readme-param-name'><code>getRankingInfo</code></div>
|
915
|
-
|
916
|
-
</div>
|
917
|
-
</div>
|
918
|
-
</td>
|
919
|
-
<td class='client-readme-param-content'>
|
920
|
-
<p>If set to 1, the result hits will contain ranking information in the <code>_rankingInfo</code> attribute.</p>
|
902
|
+
Then, within the same attribute, matches near the beginning of the text will be considered more important than matches near the end. You can disable this behavior by wrapping your attribute name inside an `unordered()` modifier. For example, `["title", "unordered(text)"]` will consider all positions inside the `text` attribute as equal, but positions inside the `title` attribute will still matter.
|
921
903
|
|
922
|
-
|
923
|
-
</tr>
|
924
|
-
|
904
|
+
**Note:** To get a full description of how the ranking works, you can have a look at our [Ranking guide](https://www.algolia.com/doc/guides/relevance/ranking).
|
925
905
|
|
926
|
-
|
927
|
-
<tr>
|
928
|
-
<td valign='top'>
|
929
|
-
<div class='client-readme-param-container'>
|
930
|
-
<div class='client-readme-param-container-inner'>
|
931
|
-
<div class='client-readme-param-name'><code>highlightPreTag</code></div>
|
932
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div><div><em>Default: <strong><em></strong></em></div></div>
|
933
|
-
</div>
|
934
|
-
</div>
|
935
|
-
</td>
|
936
|
-
<td class='client-readme-param-content'>
|
937
|
-
<p>Specify the string that is inserted before the highlighted parts in the query result (defaults to <code><em></code>).</p>
|
938
906
|
|
939
|
-
|
940
|
-
</tr>
|
941
|
-
|
907
|
+
#### attributesForFaceting
|
942
908
|
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
<div class='client-readme-param-container'>
|
947
|
-
<div class='client-readme-param-container-inner'>
|
948
|
-
<div class='client-readme-param-name'><code>highlightPostTag</code></div>
|
949
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div><div><em>Default: <strong></em></strong></em></div></div>
|
950
|
-
</div>
|
951
|
-
</div>
|
952
|
-
</td>
|
953
|
-
<td class='client-readme-param-content'>
|
954
|
-
<p>Specify the string that is inserted after the highlighted parts in the query result (defaults to <code></em></code>)</p>
|
909
|
+
- scope: `settings`
|
910
|
+
- type: `array of strings`
|
911
|
+
- default: `null`
|
955
912
|
|
956
|
-
</td>
|
957
|
-
</tr>
|
958
|
-
|
959
913
|
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
<div class='client-readme-param-container'>
|
964
|
-
<div class='client-readme-param-container-inner'>
|
965
|
-
<div class='client-readme-param-name'><code>snippetEllipsisText</code></div>
|
966
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div><div><em>Default: <strong>''</strong></em></div></div>
|
967
|
-
</div>
|
968
|
-
</div>
|
969
|
-
</td>
|
970
|
-
<td class='client-readme-param-content'>
|
971
|
-
<p>String used as an ellipsis indicator when a snippet is truncated. Defaults to an empty string for all accounts created before 10/2/2016, and to <code>…</code> (UTF-8 U+2026) for accounts created after that date.</p>
|
914
|
+
The list of attributes you want to use for faceting.
|
915
|
+
All strings within these attributes will be extracted and added as facets.
|
916
|
+
If set to `null`, no attribute is used for faceting.
|
972
917
|
|
973
|
-
</td>
|
974
|
-
</tr>
|
975
|
-
|
976
918
|
|
919
|
+
#### unretrievableAttributes
|
977
920
|
|
921
|
+
- scope: `settings`
|
922
|
+
- type: `array of strings`
|
923
|
+
- default: `null`
|
978
924
|
|
979
925
|
|
980
|
-
|
926
|
+
The list of attributes that cannot be retrieved at query time.
|
927
|
+
This feature allows you to have attributes that are used for indexing
|
928
|
+
and/or ranking but cannot be retrieved.
|
981
929
|
|
982
|
-
|
930
|
+
**Warning**: For testing purposes, this setting is ignored when you're using the **admin** API key.
|
983
931
|
|
984
|
-
|
932
|
+
#### attributesToRetrieve
|
985
933
|
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
<td valign='top'>
|
990
|
-
<div class='client-readme-param-container'>
|
991
|
-
<div class='client-readme-param-container-inner'>
|
992
|
-
<div class='client-readme-param-name'><code>numericFilters</code></div>
|
993
|
-
|
994
|
-
</div>
|
995
|
-
</div>
|
996
|
-
</td>
|
997
|
-
<td class='client-readme-param-content'>
|
998
|
-
<p>A string that contains the comma separated list of numeric filters you want to apply. The filter syntax is <code>attributeName</code> followed by <code>operand</code> followed by <code>value</code>. Supported operands are <code><</code>, <code><=</code>, <code>=</code>, <code>></code> and <code>>=</code>.</p>
|
934
|
+
- scope: `settings`, `search`
|
935
|
+
- type: `array of strings`
|
936
|
+
- default: `*`
|
999
937
|
|
1000
|
-
</td>
|
1001
|
-
</tr>
|
1002
|
-
|
1003
|
-
</tbody></table>
|
1004
938
|
|
1005
|
-
|
939
|
+
A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.
|
1006
940
|
|
1007
|
-
|
941
|
+
Attributes are separated with a comma (for example `"name,address"`).
|
942
|
+
You can also use a string array encoding (for example `["name","address"]` ).
|
943
|
+
By default, all attributes are retrieved.
|
944
|
+
You can also use `*` to retrieve all values when an **attributesToRetrieve** setting is specified for your index.
|
1008
945
|
|
1009
|
-
|
946
|
+
**Note:** `objectID` is always retrieved, even when not specified.
|
1010
947
|
|
1011
|
-
## Category Search Parameters
|
1012
948
|
|
1013
|
-
|
1014
|
-
|
1015
|
-
<tr>
|
1016
|
-
<td valign='top'>
|
1017
|
-
<div class='client-readme-param-container'>
|
1018
|
-
<div class='client-readme-param-container-inner'>
|
1019
|
-
<div class='client-readme-param-name'><code>tagFilters</code></div>
|
1020
|
-
|
1021
|
-
</div>
|
1022
|
-
</div>
|
1023
|
-
</td>
|
1024
|
-
<td class='client-readme-param-content'>
|
1025
|
-
<p>Filter the query by a set of tags. You can AND tags by separating them with commas. To OR tags, you must add parentheses. For example, <code>tagFilters=tag1,(tag2,tag3)</code> means <em>tag1 AND (tag2 OR tag3)</em>. You can also use a string array encoding. For example, <code>tagFilters: ["tag1",["tag2","tag3"]]</code> means <em>tag1 AND (tag2 OR tag3)</em>. Negations are supported via the <code>-</code> operator, prefixing the value. For example: <code>tagFilters=tag1,-tag2</code>.</p>
|
949
|
+
#### restrictSearchableAttributes
|
1026
950
|
|
1027
|
-
|
951
|
+
- scope: `search`
|
952
|
+
- type: `array of strings`
|
953
|
+
- default: `attributesToIndex`
|
1028
954
|
|
1029
|
-
</td>
|
1030
|
-
</tr>
|
1031
|
-
|
1032
|
-
</tbody></table>
|
1033
955
|
|
1034
|
-
|
956
|
+
List of attributes you want to use for textual search (must be a subset of the `attributesToIndex` index setting).
|
957
|
+
Attributes are separated with a comma such as `"name,address"`.
|
958
|
+
You can also use JSON string array encoding such as `encodeURIComponent("[\"name\",\"address\"]")`.
|
959
|
+
By default, all attributes specified in the `attributesToIndex` settings are used to search.
|
1035
960
|
|
1036
|
-
<table><tbody>
|
1037
961
|
|
1038
|
-
|
1039
|
-
<tr>
|
1040
|
-
<td valign='top'>
|
1041
|
-
<div class='client-readme-param-container'>
|
1042
|
-
<div class='client-readme-param-container-inner'>
|
1043
|
-
<div class='client-readme-param-name'><code>facetFilters</code></div>
|
1044
|
-
|
1045
|
-
</div>
|
1046
|
-
</div>
|
1047
|
-
</td>
|
1048
|
-
<td class='client-readme-param-content'>
|
1049
|
-
<p>Filter the query with a list of facets. Facets are separated by commas and is encoded as <code>attributeName:value</code>. To OR facets, you must add parentheses. For example: <code>facetFilters=(category:Book,category:Movie),author:John%20Doe</code>. You can also use a string array encoding. For example, <code>[["category:Book","category:Movie"],"author:John%20Doe"]</code>.</p>
|
962
|
+
### Ranking
|
1050
963
|
|
1051
|
-
|
1052
|
-
</tr>
|
1053
|
-
|
964
|
+
#### ranking
|
1054
965
|
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
<div class='client-readme-param-container'>
|
1059
|
-
<div class='client-readme-param-container-inner'>
|
1060
|
-
<div class='client-readme-param-name'><code>facets</code></div>
|
1061
|
-
|
1062
|
-
</div>
|
1063
|
-
</div>
|
1064
|
-
</td>
|
1065
|
-
<td class='client-readme-param-content'>
|
1066
|
-
<p>List of object attributes that you want to use for faceting. For each of the declared attributes, you'll be able to retrieve a list of the most relevant facet values, and their associated count for the current query.</p>
|
966
|
+
- scope: `settings`
|
967
|
+
- type: `array of strings`
|
968
|
+
- default: `['typo', 'geo', 'words', 'filters', 'proximity', 'attribute', 'exact', 'custom']`
|
1067
969
|
|
1068
|
-
<p>Attributes are separated by a comma. For example, <code>"category,author"</code>. You can also use JSON string array encoding. For example, <code>["category","author"]</code>. Only the attributes that have been added in <strong>attributesForFaceting</strong> index setting can be used in this parameter. You can also use <code>*</code> to perform faceting on all attributes specified in <code>attributesForFaceting</code>. If the number of results is important, the count can be approximate, the attribute <code>exhaustiveFacetsCount</code> in the response is true when the count is exact.</p>
|
1069
970
|
|
1070
|
-
|
1071
|
-
</tr>
|
1072
|
-
|
971
|
+
Controls the way results are sorted.
|
1073
972
|
|
1074
|
-
|
1075
|
-
<tr>
|
1076
|
-
<td valign='top'>
|
1077
|
-
<div class='client-readme-param-container'>
|
1078
|
-
<div class='client-readme-param-container-inner'>
|
1079
|
-
<div class='client-readme-param-name'><code>maxValuesPerFacet</code></div>
|
1080
|
-
|
1081
|
-
</div>
|
1082
|
-
</div>
|
1083
|
-
</td>
|
1084
|
-
<td class='client-readme-param-content'>
|
1085
|
-
<p>Limit the number of facet values returned for each facet. For example, <code>maxValuesPerFacet=10</code> will retrieve a maximum of 10 values per facet.</p>
|
973
|
+
We have nine available criterion:
|
1086
974
|
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
975
|
+
* `typo`: Sort according to number of typos.
|
976
|
+
* `geo`: Sort according to decreasing distance when performing a geo location based search.
|
977
|
+
* `words`: Sort according to the number of query words matched by decreasing order. This parameter is useful when you use the `optionalWords` query parameter to have results with the most matched words first.
|
978
|
+
* `proximity`: Sort according to the proximity of the query words in hits.
|
979
|
+
* `attribute`: Sort according to the order of attributes defined by attributesToIndex.
|
980
|
+
* `exact`:
|
981
|
+
* If the user query contains one word: sort objects having an attribute that is exactly the query word before others. For example, if you search for the TV show "V", you want to find it with the "V" query and avoid getting all popular TV shows starting by the letter V before it.
|
982
|
+
* If the user query contains multiple words: sort according to the number of words that matched exactly (not as a prefix).
|
983
|
+
* `custom`: Sort according to a user defined formula set in the `customRanking` attribute.
|
984
|
+
* `asc(attributeName)`: Sort according to a numeric attribute using ascending order. `attributeName` can be the name of any numeric attribute in your records (integer, double or boolean).
|
985
|
+
* `desc(attributeName)`: Sort according to a numeric attribute using descending order. `attributeName` can be the name of any numeric attribute in your records (integer, double or boolean).
|
1090
986
|
|
1091
|
-
|
987
|
+
To get a full description of how the Ranking works,
|
988
|
+
you can have a look at our [Ranking guide](https://www.algolia.com/doc/guides/relevance/ranking).
|
1092
989
|
|
1093
|
-
|
990
|
+
#### customRanking
|
1094
991
|
|
1095
|
-
|
992
|
+
- scope: `settings`
|
993
|
+
- type: `array of strings`
|
994
|
+
- default: `[]`
|
1096
995
|
|
1097
|
-
|
1098
|
-
<tr>
|
1099
|
-
<td valign='top'>
|
1100
|
-
<div class='client-readme-param-container'>
|
1101
|
-
<div class='client-readme-param-container-inner'>
|
1102
|
-
<div class='client-readme-param-name'><code>filters</code></div>
|
1103
|
-
|
1104
|
-
</div>
|
1105
|
-
</div>
|
1106
|
-
</td>
|
1107
|
-
<td class='client-readme-param-content'>
|
1108
|
-
<p>Filter the query with numeric, facet or/and tag filters. The syntax is a SQL like syntax, you can use the OR and AND keywords. The syntax for the underlying numeric, facet and tag filters is the same than in the other filters:
|
1109
|
-
<code>available=1 AND (category:Book OR NOT category:Ebook) AND _tags:public</code>
|
1110
|
-
<code>date: 1441745506 TO 1441755506 AND inStock > 0 AND author:"John Doe"</code></p>
|
1111
996
|
|
1112
|
-
|
997
|
+
Lets you specify part of the ranking.
|
1113
998
|
|
1114
|
-
|
999
|
+
The syntax of this condition is an array of strings containing attributes
|
1000
|
+
prefixed by the asc (ascending order) or desc (descending order) operator.
|
1115
1001
|
|
1116
|
-
|
1117
|
-
<li><code>OR</code>: create a disjunctive filter between two filters.</li>
|
1118
|
-
<li><code>AND</code>: create a conjunctive filter between two filters.</li>
|
1119
|
-
<li><code>TO</code>: used to specify a range for a numeric filter.</li>
|
1120
|
-
<li><code>NOT</code>: used to negate a filter. The syntax with the <code>-</code> isn’t allowed.</li>
|
1121
|
-
</ul>
|
1002
|
+
For example, `"customRanking" => ["desc(population)", "asc(name)"]`.
|
1122
1003
|
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
</tbody></table>
|
1127
|
-
*Note*: To specify a value with spaces or with a value equal to a keyword, it's possible to add quotes.
|
1004
|
+
To get a full description of how the Custom Ranking works,
|
1005
|
+
you can have a look at our [Ranking guide](https://www.algolia.com/doc/guides/relevance/ranking).
|
1128
1006
|
|
1129
|
-
|
1007
|
+
#### slaves
|
1130
1008
|
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1009
|
+
- scope: `settings`
|
1010
|
+
- type: `array of strings`
|
1011
|
+
- default: `[]`
|
1134
1012
|
|
1135
1013
|
|
1136
|
-
|
1014
|
+
The list of indices on which you want to replicate all write operations.
|
1137
1015
|
|
1138
|
-
|
1016
|
+
In order to get response times in milliseconds, we pre-compute part of the ranking during indexing.
|
1139
1017
|
|
1140
|
-
|
1141
|
-
|
1142
|
-
<td valign='top'>
|
1143
|
-
<div class='client-readme-param-container'>
|
1144
|
-
<div class='client-readme-param-container-inner'>
|
1145
|
-
<div class='client-readme-param-name'><code>distinct</code></div>
|
1146
|
-
|
1147
|
-
</div>
|
1148
|
-
</div>
|
1149
|
-
</td>
|
1150
|
-
<td class='client-readme-param-content'>
|
1151
|
-
<p>If set to 1, enables the distinct feature, disabled by default, if the <code>attributeForDistinct</code> index setting is set. This feature is similar to the SQL "distinct" keyword. When enabled in a query with the <code>distinct=1</code> parameter, all hits containing a duplicate value for the attributeForDistinct attribute are removed from results. For example, if the chosen attribute is <code>show_name</code> and several hits have the same value for <code>show_name</code>, then only the best one is kept and the others are removed.</p>
|
1018
|
+
If you want to use different ranking configurations depending of the use case,
|
1019
|
+
you need to create one index per ranking configuration.
|
1152
1020
|
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1021
|
+
This option enables you to perform write operations only on this index and automatically
|
1022
|
+
update slave indices with the same operations.
|
1156
1023
|
|
1157
|
-
|
1024
|
+
### Filtering / Faceting
|
1158
1025
|
|
1159
|
-
|
1026
|
+
#### filters
|
1160
1027
|
|
1028
|
+
- scope: `search`
|
1029
|
+
- type: `string`
|
1030
|
+
- default: `""`
|
1161
1031
|
|
1162
1032
|
|
1033
|
+
Filter the query with numeric, facet or/and tag filters.
|
1163
1034
|
|
1035
|
+
The syntax is a SQL like syntax, you can use the OR and AND keywords.
|
1036
|
+
The syntax for the underlying numeric, facet and tag filters is the same than in the other filters:
|
1164
1037
|
|
1165
|
-
|
1166
|
-
|
1038
|
+
`available=1 AND (category:Book OR NOT category:Ebook) AND _tags:public`
|
1039
|
+
`date: 1441745506 TO 1441755506 AND inStock > 0 AND author:"John Doe"`
|
1167
1040
|
|
1168
|
-
|
1041
|
+
If no attribute name is specified,
|
1042
|
+
the filter applies to `_tags`.
|
1169
1043
|
|
1170
|
-
|
1171
|
-
# perform 3 queries in a single API call:
|
1172
|
-
# - 1st query targets index `categories`
|
1173
|
-
# - 2nd and 3rd queries target index `products`
|
1174
|
-
res = Algolia.multiple_queries([{:index_name => "categories", "query" => my_query_string, "hitsPerPage" => 3}
|
1175
|
-
, {:index_name => "products", "query" => my_query_string, "hitsPerPage" => 3, "filters" => "_tags:promotion"}
|
1176
|
-
, {:index_name => "products", "query" => my_query_string, "hitsPerPage" => 10}])
|
1044
|
+
For example: `public OR user_42` will translate to `_tags:public OR _tags:user_42`.
|
1177
1045
|
|
1178
|
-
|
1179
|
-
```
|
1046
|
+
The list of keywords is:
|
1180
1047
|
|
1181
|
-
|
1048
|
+
* `OR`: create a disjunctive filter between two filters.
|
1049
|
+
* `AND`: create a conjunctive filter between two filters.
|
1050
|
+
* `TO`: used to specify a range for a numeric filter.
|
1051
|
+
* `NOT`: used to negate a filter. The syntax with the `-` isn’t allowed.
|
1182
1052
|
|
1183
|
-
|
1184
|
-
- `none`: Execute the sequence of queries until the end.
|
1185
|
-
- `stopIfEnoughMatches`: Execute the sequence of queries until the number of hits is reached by the sum of hits.
|
1053
|
+
**Note:** To specify a value with spaces or with a value equal to a keyword, it's possible to add quotes.
|
1186
1054
|
|
1055
|
+
**Warnings:**
|
1187
1056
|
|
1057
|
+
* Like for the other filters (for performance reasons), it's not possible to have `FILTER1 OR (FILTER2 AND FILTER3)`.
|
1058
|
+
* It is not possible to mix different categories of filters inside an OR like: `num=3 OR tag1 OR facet:value`.
|
1059
|
+
* It is not possible to negate a group; only individual filters can be negated: `NOT(FILTER1 OR (FILTER2))` is not allowed.
|
1188
1060
|
|
1189
|
-
Get an object
|
1190
|
-
==================
|
1191
1061
|
|
1192
|
-
|
1062
|
+
#### facets
|
1193
1063
|
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
#
|
1200
|
-
|
1064
|
+
- scope: `search`
|
1065
|
+
- type: `string`
|
1066
|
+
- default: `""`
|
1067
|
+
|
1068
|
+
|
1069
|
+
You can use [facets](#facets) to retrieve only a part of your attributes declared in
|
1070
|
+
**[attributesForFaceting](#attributesforfaceting)** attributes.
|
1071
|
+
It will not filter your results, if you want to filter results you should use [filters](#filters).
|
1072
|
+
|
1073
|
+
For each of the declared attributes, you'll be able to retrieve a list of the most relevant facet values,
|
1074
|
+
and their associated count for the current query.
|
1075
|
+
|
1076
|
+
**Example**
|
1077
|
+
|
1078
|
+
If you have defined in your **[attributesForFaceting](#attributesforfaceting)**:
|
1079
|
+
|
1080
|
+
```
|
1081
|
+
["category", "author", "nb_views", "nb_downloads"]
|
1201
1082
|
```
|
1202
1083
|
|
1203
|
-
|
1084
|
+
... but, for the current search, you want to retrieve facet values only for `category` and `author`, then you can specify:
|
1204
1085
|
|
1205
|
-
```
|
1206
|
-
|
1086
|
+
```
|
1087
|
+
["category", "author"]
|
1207
1088
|
```
|
1208
1089
|
|
1209
|
-
|
1210
|
-
==================
|
1090
|
+
**Warnings**
|
1211
1091
|
|
1212
|
-
|
1092
|
+
- When using [facets](#facets) in a search query, only attributes that have been added in **attributesForFaceting** index setting can be used in this parameter.
|
1093
|
+
You can also use `*` to perform faceting on all attributes specified in `attributesForFaceting`.
|
1094
|
+
If the number of results is important, the count can be approximate,
|
1095
|
+
the attribute `exhaustiveFacetsCount` in the response is true when the count is exact.
|
1213
1096
|
|
1214
|
-
|
1215
|
-
index.delete_object("myID")
|
1216
|
-
```
|
1097
|
+
#### maxValuesPerFacet
|
1217
1098
|
|
1218
|
-
|
1219
|
-
|
1099
|
+
- scope: `settings`, `search`
|
1100
|
+
- type: `integer`
|
1101
|
+
- default: `""`
|
1220
1102
|
|
1221
|
-
You can delete all objects matching a single query with the following code. Internally, the API client performs the query, deletes all matching hits, and waits until the deletions have been applied.
|
1222
1103
|
|
1104
|
+
Limit the number of facet values returned for each facet.
|
1223
1105
|
|
1224
|
-
|
1225
|
-
params = {}
|
1226
|
-
index.delete_by_query("John", params)
|
1227
|
-
```
|
1106
|
+
For example, `maxValuesPerFacet=10` will retrieve a maximum of 10 values per facet.
|
1228
1107
|
|
1108
|
+
### Highlighting / Snippeting
|
1229
1109
|
|
1230
|
-
|
1231
|
-
==================
|
1110
|
+
#### attributesToHighlight
|
1232
1111
|
|
1233
|
-
|
1112
|
+
- scope: `settings`, `search`
|
1113
|
+
- type: `array of strings`
|
1114
|
+
- default: `null`
|
1234
1115
|
|
1235
|
-
```ruby
|
1236
|
-
res = index.get_settings
|
1237
|
-
puts settings.to_json
|
1238
|
-
```
|
1239
1116
|
|
1240
|
-
|
1241
|
-
|
1242
|
-
```
|
1117
|
+
Default list of attributes to highlight.
|
1118
|
+
If set to null, all indexed attributes are highlighted.
|
1243
1119
|
|
1244
|
-
|
1120
|
+
A string that contains the list of attributes you want to highlight according to the query.
|
1121
|
+
Attributes are separated by commas.
|
1122
|
+
You can also use a string array encoding (for example `["name","address"]`).
|
1123
|
+
If an attribute has no match for the query, the raw value is returned.
|
1124
|
+
By default, all indexed attributes are highlighted (as long as they are strings).
|
1125
|
+
You can use `*` if you want to highlight all attributes.
|
1245
1126
|
|
1246
|
-
|
1127
|
+
A matchLevel is returned for each highlighted attribute and can contain:
|
1247
1128
|
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1129
|
+
* `full`: If all the query terms were found in the attribute.
|
1130
|
+
* `partial`: If only some of the query terms were found.
|
1131
|
+
* `none`: If none of the query terms were found.
|
1251
1132
|
|
1252
|
-
|
1133
|
+
#### attributesToSnippet
|
1253
1134
|
|
1254
|
-
|
1135
|
+
- scope: `settings`, `search`
|
1136
|
+
- type: `array of strings`
|
1137
|
+
- default: `null`
|
1255
1138
|
|
1256
|
-
|
1257
|
-
<tr>
|
1258
|
-
<td valign='top'>
|
1259
|
-
<div class='client-readme-param-container'>
|
1260
|
-
<div class='client-readme-param-container-inner'>
|
1261
|
-
<div class='client-readme-param-name'><code>attributesToIndex</code></div>
|
1262
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1263
|
-
</div>
|
1264
|
-
</div>
|
1265
|
-
</td>
|
1266
|
-
<td class='client-readme-param-content'>
|
1267
|
-
<p>The list of attributes you want index (i.e. to make searchable).</p>
|
1268
1139
|
|
1269
|
-
|
1140
|
+
Default list of attributes to snippet alongside the number of words to return (syntax is `attributeName:nbWords`).
|
1141
|
+
If set to null, no snippet is computed.
|
1270
1142
|
|
1271
|
-
|
1143
|
+
#### highlightPreTag
|
1272
1144
|
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
You can decide to have the same priority for two attributes by passing them in the same string using a comma as a separator. For example <code>title</code> and <code>alternative_title</code> have the same priority in this example, which is different than text priority: <code>attributesToIndex:["title,alternative_title", "text"]</code>.
|
1277
|
-
To get a full description of how the Ranking works, you can have a look at our <a href="https://www.algolia.com/doc/relevance/ranking">Ranking guide</a>.</li>
|
1278
|
-
<li><strong>numericAttributesToIndex</strong>: (array of strings) All numerical attributes are automatically indexed as numerical filters (allowing filtering operations like <code><</code> and <code><=</code>). If you don't need filtering on some of your numerical attributes, you can specify this list to speed up the indexing.<br/> If you only need to filter on a numeric value with the operator '=', you can speed up the indexing by specifying the attribute with <code>equalOnly(AttributeName)</code>. The other operators will be disabled.</li>
|
1279
|
-
</ul>
|
1145
|
+
- scope: `settings`, `search`
|
1146
|
+
- type: `string`
|
1147
|
+
- default: `<em>`
|
1280
1148
|
|
1281
|
-
</td>
|
1282
|
-
</tr>
|
1283
|
-
|
1284
1149
|
|
1285
|
-
|
1286
|
-
<tr>
|
1287
|
-
<td valign='top'>
|
1288
|
-
<div class='client-readme-param-container'>
|
1289
|
-
<div class='client-readme-param-container-inner'>
|
1290
|
-
<div class='client-readme-param-name'><code>attributesForFaceting</code></div>
|
1291
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1292
|
-
</div>
|
1293
|
-
</div>
|
1294
|
-
</td>
|
1295
|
-
<td class='client-readme-param-content'>
|
1296
|
-
<p>The list of fields you want to use for faceting. All strings in the attribute selected for faceting are extracted and added as a facet. If set to null, no attribute is used for faceting.</p>
|
1150
|
+
Specify the string that is inserted before the highlighted parts in the query result (defaults to `<em>`).
|
1297
1151
|
|
1298
|
-
</td>
|
1299
|
-
</tr>
|
1300
|
-
|
1301
1152
|
|
1302
|
-
|
1303
|
-
<tr>
|
1304
|
-
<td valign='top'>
|
1305
|
-
<div class='client-readme-param-container'>
|
1306
|
-
<div class='client-readme-param-container-inner'>
|
1307
|
-
<div class='client-readme-param-name'><code>attributeForDistinct</code></div>
|
1308
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div></div>
|
1309
|
-
</div>
|
1310
|
-
</div>
|
1311
|
-
</td>
|
1312
|
-
<td class='client-readme-param-content'>
|
1313
|
-
<p>The name of the attribute used for the <code>Distinct</code> feature. This feature is similar to the SQL "distinct" keyword. When enabled in queries with the <code>distinct=1</code> parameter, all hits containing a duplicate value for this attribute are removed from the results. For example, if the chosen attribute is <code>show_name</code> and several hits have the same value for <code>show_name</code>, then only the first one is kept and the others are removed from the results. To get a full understanding of how <code>Distinct</code> works, you can have a look at our <a href="https://www.algolia.com/doc/search/distinct">guide on distinct</a>.</p>
|
1314
1153
|
|
1315
|
-
|
1316
|
-
</tr>
|
1317
|
-
|
1154
|
+
#### highlightPostTag
|
1318
1155
|
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
<div class='client-readme-param-container'>
|
1323
|
-
<div class='client-readme-param-container-inner'>
|
1324
|
-
<div class='client-readme-param-name'><code>ranking</code></div>
|
1325
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1326
|
-
</div>
|
1327
|
-
</div>
|
1328
|
-
</td>
|
1329
|
-
<td class='client-readme-param-content'>
|
1330
|
-
<p>Controls the way results are sorted.</p>
|
1156
|
+
- scope: `settings`, `search`
|
1157
|
+
- type: `string`
|
1158
|
+
- default: `</em>`
|
1331
1159
|
|
1332
|
-
<p>We have nine available criteria:</p>
|
1333
1160
|
|
1334
|
-
|
1335
|
-
<li><code>typo</code>: Sort according to number of typos.</li>
|
1336
|
-
<li><code>geo</code>: Sort according to decreasing distance when performing a geo location based search.</li>
|
1337
|
-
<li><code>words</code>: Sort according to the number of query words matched by decreasing order. This parameter is useful when you use the <code>optionalWords</code> query parameter to have results with the most matched words first.</li>
|
1338
|
-
<li><code>proximity</code>: Sort according to the proximity of the query words in hits.</li>
|
1339
|
-
<li><code>attribute</code>: Sort according to the order of attributes defined by attributesToIndex.</li>
|
1340
|
-
<li><code>exact</code>:
|
1161
|
+
Specify the string that is inserted after the highlighted parts in the query result (defaults to `</em>`).
|
1341
1162
|
|
1342
|
-
<ul>
|
1343
|
-
<li>If the user query contains one word: sort objects having an attribute that is exactly the query word before others. For example, if you search for the TV show "V", you want to find it with the "V" query and avoid getting all popular TV shows starting by the letter V before it.</li>
|
1344
|
-
<li>If the user query contains multiple words: sort according to the number of words that matched exactly (not as a prefix).</li>
|
1345
|
-
</ul></li>
|
1346
|
-
<li><code>custom</code>: Sort according to a user defined formula set in the <code>customRanking</code> attribute.</li>
|
1347
|
-
<li><code>asc(attributeName)</code>: Sort according to a numeric attribute using ascending order. <code>attributeName</code> can be the name of any numeric attribute in your records (integer, double or boolean).</li>
|
1348
|
-
<li><code>desc(attributeName)</code>: Sort according to a numeric attribute using descending order. <code>attributeName</code> can be the name of any numeric attribute in your records (integer, double or boolean). <br/>The standard order is <code>["typo", "geo", "words", "proximity", "attribute", "exact", "custom"]</code>.
|
1349
|
-
To get a full description of how the Ranking works, you can have a look at our <a href="https://www.algolia.com/doc/relevance/ranking">Ranking guide</a>.</li>
|
1350
|
-
</ul>
|
1351
1163
|
|
1352
|
-
</td>
|
1353
|
-
</tr>
|
1354
|
-
|
1355
1164
|
|
1356
|
-
|
1357
|
-
<tr>
|
1358
|
-
<td valign='top'>
|
1359
|
-
<div class='client-readme-param-container'>
|
1360
|
-
<div class='client-readme-param-container-inner'>
|
1361
|
-
<div class='client-readme-param-name'><code>customRanking</code></div>
|
1362
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1363
|
-
</div>
|
1364
|
-
</div>
|
1365
|
-
</td>
|
1366
|
-
<td class='client-readme-param-content'>
|
1367
|
-
<p>Lets you specify part of the ranking.</p>
|
1165
|
+
#### snippetEllipsisText
|
1368
1166
|
|
1369
|
-
|
1167
|
+
- scope: `settings`, `search`
|
1168
|
+
- type: `string`
|
1169
|
+
- default: `…`
|
1370
1170
|
|
1371
|
-
<p>To get a full description of how the Custom Ranking works, you can have a look at our <a href="https://www.algolia.com/doc/relevance/ranking">Ranking guide</a>.</p>
|
1372
1171
|
|
1373
|
-
|
1374
|
-
</tr>
|
1375
|
-
|
1172
|
+
String used as an ellipsis indicator when a snippet is truncated.
|
1376
1173
|
|
1377
|
-
|
1378
|
-
<tr>
|
1379
|
-
<td valign='top'>
|
1380
|
-
<div class='client-readme-param-container'>
|
1381
|
-
<div class='client-readme-param-container-inner'>
|
1382
|
-
<div class='client-readme-param-name'><code>queryType</code></div>
|
1383
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>prefixLast</strong></em></div></div>
|
1384
|
-
</div>
|
1385
|
-
</div>
|
1386
|
-
</td>
|
1387
|
-
<td class='client-readme-param-content'>
|
1388
|
-
<p>Select how the query words are interpreted. It can be one of the following values:</p>
|
1174
|
+
**Note:** Defaults to an empty string for all accounts created before 10/2/2016, and to `…` (U+2026) for accounts created after that date.
|
1389
1175
|
|
1390
|
-
|
1391
|
-
<li><code>prefixAll</code>: All query words are interpreted as prefixes.</li>
|
1392
|
-
<li><code>prefixLast</code>: Only the last word is interpreted as a prefix (default behavior).</li>
|
1393
|
-
<li><code>prefixNone</code>: No query word is interpreted as a prefix. This option is not recommended.</li>
|
1394
|
-
</ul>
|
1176
|
+
#### restrictHighlightAndSnippetArrays
|
1395
1177
|
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1178
|
+
- scope: `settings`, `search`
|
1179
|
+
- type: `boolean`
|
1180
|
+
- default: `false`
|
1399
1181
|
|
1400
|
-
|
1401
|
-
<tr>
|
1402
|
-
<td valign='top'>
|
1403
|
-
<div class='client-readme-param-container'>
|
1404
|
-
<div class='client-readme-param-container-inner'>
|
1405
|
-
<div class='client-readme-param-name'><code>separatorsToIndex</code></div>
|
1406
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>empty</strong></em></div></div>
|
1407
|
-
</div>
|
1408
|
-
</div>
|
1409
|
-
</td>
|
1410
|
-
<td class='client-readme-param-content'>
|
1411
|
-
<p>Specify the separators (punctuation characters) to index. By default, separators are not indexed. Use <code>+#</code> to be able to search Google+ or C#.</p>
|
1412
1182
|
|
1413
|
-
|
1414
|
-
</tr>
|
1415
|
-
|
1183
|
+
If set to true, restrict arrays in highlights and snippets to items that matched the query at least partially else return all array items in highlights and snippets.
|
1416
1184
|
|
1417
|
-
|
1418
|
-
<tr>
|
1419
|
-
<td valign='top'>
|
1420
|
-
<div class='client-readme-param-container'>
|
1421
|
-
<div class='client-readme-param-container-inner'>
|
1422
|
-
<div class='client-readme-param-name'><code>slaves</code></div>
|
1423
|
-
|
1424
|
-
</div>
|
1425
|
-
</div>
|
1426
|
-
</td>
|
1427
|
-
<td class='client-readme-param-content'>
|
1428
|
-
<p>The list of indices on which you want to replicate all write operations. In order to get response times in milliseconds, we pre-compute part of the ranking during indexing. If you want to use different ranking configurations depending of the use case, you need to create one index per ranking configuration. This option enables you to perform write operations only on this index and automatically update slave indices with the same operations.</p>
|
1185
|
+
### Pagination
|
1429
1186
|
|
1430
|
-
|
1431
|
-
</tr>
|
1432
|
-
|
1187
|
+
#### page
|
1433
1188
|
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
<div class='client-readme-param-container'>
|
1438
|
-
<div class='client-readme-param-container-inner'>
|
1439
|
-
<div class='client-readme-param-name'><code>unretrievableAttributes</code></div>
|
1440
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>empty</strong></em></div></div>
|
1441
|
-
</div>
|
1442
|
-
</div>
|
1443
|
-
</td>
|
1444
|
-
<td class='client-readme-param-content'>
|
1445
|
-
<p>The list of attributes that cannot be retrieved at query time. This feature allows you to have attributes that are used for indexing and/or ranking but cannot be retrieved. Defaults to null. Warning: for testing purposes, this setting is ignored when you're using the ADMIN API Key.</p>
|
1189
|
+
- scope: `search`
|
1190
|
+
- type: `integer`
|
1191
|
+
- default: `0`
|
1446
1192
|
|
1447
|
-
</td>
|
1448
|
-
</tr>
|
1449
|
-
|
1450
1193
|
|
1451
|
-
|
1452
|
-
<tr>
|
1453
|
-
<td valign='top'>
|
1454
|
-
<div class='client-readme-param-container'>
|
1455
|
-
<div class='client-readme-param-container-inner'>
|
1456
|
-
<div class='client-readme-param-name'><code>allowCompressionOfIntegerArray</code></div>
|
1457
|
-
<div class="client-readme-param-meta"><div><em>Default: <strong>false</strong></em></div></div>
|
1458
|
-
</div>
|
1459
|
-
</div>
|
1460
|
-
</td>
|
1461
|
-
<td class='client-readme-param-content'>
|
1462
|
-
<p>Allows compression of big integer arrays. In data-intensive use-cases, we recommended enabling this feature and then storing the list of user IDs or rights as an integer array. When enabled, the integer array is reordered to reach a better compression ratio. Defaults to false.</p>
|
1194
|
+
Pagination parameter used to select the page to retrieve.
|
1463
1195
|
|
1464
|
-
|
1465
|
-
</tr>
|
1466
|
-
|
1196
|
+
**Warning:** Page is zero based. Thus, to retrieve the 10th page, you need to set `page=9`.
|
1467
1197
|
|
1468
|
-
|
1198
|
+
#### hitsPerPage
|
1469
1199
|
|
1470
|
-
|
1200
|
+
- scope: `settings`, `search`
|
1201
|
+
- type: `integer`
|
1202
|
+
- default: `20`
|
1471
1203
|
|
1472
|
-
<table><tbody>
|
1473
|
-
|
1474
|
-
<tr>
|
1475
|
-
<td valign='top'>
|
1476
|
-
<div class='client-readme-param-container'>
|
1477
|
-
<div class='client-readme-param-container-inner'>
|
1478
|
-
<div class='client-readme-param-name'><code>synonyms</code></div>
|
1479
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of array of string considered as equals</strong></em></div></div>
|
1480
|
-
</div>
|
1481
|
-
</div>
|
1482
|
-
</td>
|
1483
|
-
<td class='client-readme-param-content'>
|
1484
|
-
<p>For example, you may want to retrieve the <strong>black ipad</strong> record when your users are searching for <strong>dark ipad</strong>, even if the word <strong>dark</strong> is not part of the record. To do this, you need to configure <strong>black</strong> as a synonym of <strong>dark</strong>. For example, <code>"synomyms": [ [ "black", "dark" ], [ "small", "little", "mini" ], ... ]</code>. The Synonym feature also supports multi-words expressions like <code>"synonyms": [ ["NYC", "New York City"] ]</code></p>
|
1485
1204
|
|
1486
|
-
|
1487
|
-
</tr>
|
1488
|
-
|
1489
|
-
|
1490
|
-
<tr>
|
1491
|
-
<td valign='top'>
|
1492
|
-
<div class='client-readme-param-container'>
|
1493
|
-
<div class='client-readme-param-container-inner'>
|
1494
|
-
<div class='client-readme-param-name'><code>placeholders</code></div>
|
1495
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>hash of array of words</strong></em></div></div>
|
1496
|
-
</div>
|
1497
|
-
</div>
|
1498
|
-
</td>
|
1499
|
-
<td class='client-readme-param-content'>
|
1500
|
-
<p>This is an advanced use-case to define a token substitutable by a list of words without having the original token searchable. It is defined by a hash associating placeholders to lists of substitutable words. For example, <code>"placeholders": { "<streetnumber>": ["1", "2", "3", ..., "9999"]}</code> would allow it to be able to match all street numbers. We use the <code>< ></code> tag syntax to define placeholders in an attribute. For example:</p>
|
1205
|
+
Pagination parameter used to select the number of hits per page.
|
1501
1206
|
|
1502
|
-
|
1503
|
-
<li>Push a record with the placeholder: <code>{ "name" : "Apple Store", "address" : "&lt;streetnumber&gt; Opera street, Paris" }</code>.</li>
|
1504
|
-
<li>Configure the placeholder in your index settings: <code>"placeholders": { "<streetnumber>" : ["1", "2", "3", "4", "5", ... ], ... }</code>.</li>
|
1505
|
-
</ul>
|
1207
|
+
### Typos
|
1506
1208
|
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1209
|
+
#### minWordSizefor1Typo
|
1210
|
+
|
1211
|
+
- scope: `settings`, `search`
|
1212
|
+
- type: `integer`
|
1213
|
+
- default: `4`
|
1214
|
+
|
1215
|
+
|
1216
|
+
The minimum number of characters needed to accept one typo.
|
1217
|
+
|
1218
|
+
#### minWordSizefor2Typos
|
1219
|
+
|
1220
|
+
- scope: `settings`, `search`
|
1221
|
+
- type: `integer`
|
1222
|
+
- default: `8`
|
1223
|
+
|
1224
|
+
|
1225
|
+
The minimum number of characters needed to accept two typos.
|
1226
|
+
|
1227
|
+
#### typoTolerance
|
1228
|
+
|
1229
|
+
- scope: `settings`, `search`
|
1230
|
+
- type: `boolean`
|
1231
|
+
- default: `true`
|
1232
|
+
|
1233
|
+
|
1234
|
+
This option allows you to control the number of typos allowed in the result set:
|
1235
|
+
|
1236
|
+
* `true`: The typo tolerance is enabled and all matching hits are retrieved (default behavior).
|
1237
|
+
* `false`: The typo tolerance is disabled. All results with typos will be hidden.
|
1238
|
+
* `min`: Only keep results with the minimum number of typos. For example, if one result matches without typos, then all results with typos will be hidden.
|
1239
|
+
* `strict`: Hits matching with 2 typos are not retrieved if there are some matching without typos.
|
1240
|
+
|
1241
|
+
|
1242
|
+
#### allowTyposOnNumericTokens
|
1243
|
+
|
1244
|
+
- scope: `settings`, `search`
|
1245
|
+
- type: `boolean`
|
1246
|
+
- default: `true`
|
1247
|
+
|
1248
|
+
|
1249
|
+
If set to false, disables typo tolerance on numeric tokens (numbers).
|
1250
|
+
|
1251
|
+
#### ignorePlurals
|
1252
|
+
|
1253
|
+
- scope: `settings`, `search`
|
1254
|
+
- type: `boolean`
|
1255
|
+
- default: `false`
|
1256
|
+
|
1257
|
+
|
1258
|
+
If set to true, plural won't be considered as a typo. For example, car and cars, or foot and feet will be considered as equivalent. Defaults to false.
|
1259
|
+
|
1260
|
+
#### disableTypoToleranceOnAttributes
|
1261
|
+
|
1262
|
+
- scope: `settings`, `search`
|
1263
|
+
- type: `string`
|
1264
|
+
- default: `""`
|
1265
|
+
|
1266
|
+
|
1267
|
+
List of attributes on which you want to disable typo tolerance
|
1268
|
+
(must be a subset of the `attributesToIndex` index setting).
|
1269
|
+
|
1270
|
+
Attributes are separated with a comma such as `"name,address"`.
|
1271
|
+
You can also use JSON string array encoding such as `encodeURIComponent("[\"name\",\"address\"]")`.
|
1272
|
+
|
1273
|
+
#### separatorsToIndex
|
1274
|
+
|
1275
|
+
- scope: `settings`
|
1276
|
+
- type: `string`
|
1277
|
+
- default: `""`
|
1278
|
+
|
1279
|
+
|
1280
|
+
Specify the separators (punctuation characters) to index.
|
1281
|
+
|
1282
|
+
By default, separators are not indexed.
|
1283
|
+
|
1284
|
+
**Example:** Use `+#` to be able to search for "Google+" or "C#".
|
1285
|
+
|
1286
|
+
|
1287
|
+
|
1288
|
+
### Geo-Search
|
1289
|
+
|
1290
|
+
Geo search requires that you provide at least one geo location in each record at indexing time, under the `_geoloc` attribute. Each location must be an object with two numeric `lat` and `lng` attributes. You may specify either one location:
|
1291
|
+
|
1292
|
+
```
|
1293
|
+
{
|
1294
|
+
"_geoloc": {
|
1295
|
+
"lat": 48.853409,
|
1296
|
+
"lng": 2.348800
|
1297
|
+
}
|
1298
|
+
}
|
1299
|
+
```
|
1300
|
+
|
1301
|
+
... or an array of locations:
|
1302
|
+
|
1303
|
+
```
|
1304
|
+
{
|
1305
|
+
"_geoloc": [
|
1306
|
+
{
|
1307
|
+
"lat": 48.853409,
|
1308
|
+
"lng": 2.348800
|
1309
|
+
},
|
1310
|
+
{
|
1311
|
+
"lat": 48.547456,
|
1312
|
+
"lng": 2.972075
|
1313
|
+
}
|
1314
|
+
]
|
1315
|
+
}
|
1316
|
+
```
|
1317
|
+
|
1318
|
+
|
1319
|
+
|
1320
|
+
|
1321
|
+
#### aroundLatLng
|
1322
|
+
|
1323
|
+
- scope: `search`
|
1324
|
+
- type: `string`
|
1325
|
+
- default: ``
|
1326
|
+
|
1327
|
+
|
1328
|
+
Search for entries around a given location (specified as two floats separated by a comma).
|
1329
|
+
|
1330
|
+
For example, `aroundLatLng=47.316669,5.016670`.
|
1331
|
+
|
1332
|
+
- By default the maximum distance is automatically guessed based on the density of the area
|
1333
|
+
but you can specify it manually in meters with the **aroundRadius** parameter.
|
1334
|
+
The precision for ranking can be set with **aroundPrecision** parameter.
|
1335
|
+
- If you set aroundPrecision=100, the distances will be considered by ranges of 100m.
|
1336
|
+
- For example all distances 0 and 100m will be considered as identical for the "geo" ranking parameter.
|
1337
|
+
|
1338
|
+
When `aroundRadius` is not set, the radius is computed automatically using the density of the area; you can retrieve the computed value in the `automaticRadius` attribute of the response.
|
1339
|
+
You can also use the `minimumAroundRadius` query parameter to specify a minimum radius in meters for the automatic computation of `aroundRadius`.
|
1340
|
+
|
1341
|
+
|
1342
|
+
|
1343
|
+
|
1344
|
+
|
1345
|
+
#### aroundLatLngViaIP
|
1346
|
+
|
1347
|
+
- scope: `search`
|
1348
|
+
- type: `string`
|
1349
|
+
- default: `false`
|
1350
|
+
|
1351
|
+
|
1352
|
+
Search for entries around a given latitude/longitude automatically computed from user IP address.
|
1353
|
+
|
1354
|
+
To enable it, use `aroundLatLngViaIP=true`.
|
1355
|
+
|
1356
|
+
You can specify the maximum distance in meters with the `aroundRadius` parameter
|
1357
|
+
and the precision for ranking with `aroundPrecision`.
|
1358
|
+
|
1359
|
+
For example:
|
1360
|
+
- if you set aroundPrecision=100,
|
1361
|
+
two objects that are in the range 0-99m
|
1362
|
+
will be considered as identical in the ranking for the "geo" ranking parameter (same for 100-199, 200-299, ... ranges).
|
1363
|
+
|
1364
|
+
|
1365
|
+
|
1366
|
+
#### aroundRadius
|
1367
|
+
|
1368
|
+
- scope: `search`
|
1369
|
+
- type: `integer`, `"all"`
|
1370
|
+
- default: `null`
|
1371
|
+
|
1372
|
+
|
1373
|
+
Control the radius associated with a geo search. Defined in meters.
|
1374
|
+
|
1375
|
+
If not set, the radius is computed automatically using the density of the area. You can retrieve the computed radius in the `automaticRadius` attribute of the response. You can also specify a minimum value for the automatic radius by using the `minimumAroundRadius` query parameter. You can specify `aroundRadius=all` if you want to compute the geo distance without filtering in a geo area; this option will be faster than specifying a big integer value.
|
1376
|
+
|
1377
|
+
#### aroundPrecision
|
1378
|
+
|
1379
|
+
- scope: `search`
|
1380
|
+
- type: `integer`
|
1381
|
+
- default: `null`
|
1382
|
+
|
1383
|
+
|
1384
|
+
Control the precision of a geo search. Defined in meters. For example, if you set `aroundPrecision=100`, two objects that are in the range 0-99m will be considered as identical in the ranking for the `geo` ranking parameter (same for 100-199, 200-299, … ranges).
|
1385
|
+
|
1386
|
+
#### minimumAroundRadius
|
1387
|
+
|
1388
|
+
- scope: `search`
|
1389
|
+
- type: `integer`
|
1390
|
+
- default: `null`
|
1391
|
+
|
1392
|
+
|
1393
|
+
Define the minimum radius used for a geo search when `aroundRadius` is not set. The radius is computed automatically using the density of the area. You can retrieve the computed radius in the `automaticRadius` attribute of the answer.
|
1394
|
+
|
1395
|
+
#### insideBoundingBox
|
1396
|
+
|
1397
|
+
- scope: `search`
|
1398
|
+
- type: `string`
|
1399
|
+
- default: `null`
|
1400
|
+
|
1401
|
+
|
1402
|
+
Search entries inside a given area defined by the two extreme points of a rectangle
|
1403
|
+
(defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng).
|
1404
|
+
For example:
|
1405
|
+
- `insideBoundingBox=47.3165,4.9665,47.3424,5.0201`
|
1406
|
+
|
1407
|
+
You can use several bounding boxes (OR) by passing more than 4 values.
|
1408
|
+
For example: instead of having 4 values you can pass 8 to search inside the UNION of two bounding boxes.
|
1409
|
+
|
1410
|
+
#### insidePolygon
|
1411
|
+
|
1412
|
+
- scope: `search`
|
1413
|
+
- type: `string`
|
1414
|
+
- default: ``
|
1415
|
+
|
1416
|
+
|
1417
|
+
Search entries inside a given area defined by a set of points
|
1418
|
+
(defined by a minimum of 6 floats: p1Lat,p1Lng,p2Lat,p2Lng,p3Lat,p3Long).
|
1419
|
+
|
1420
|
+
For example:
|
1421
|
+
`InsidePolygon=47.3165,4.9665,47.3424,5.0201,47.32,4.98`).
|
1422
|
+
|
1423
|
+
|
1424
|
+
### Query Strategy
|
1425
|
+
|
1426
|
+
#### queryType
|
1427
|
+
|
1428
|
+
- scope: `settings`, `search`
|
1429
|
+
- type: `enum`
|
1430
|
+
- default: `'prefixLast'`
|
1431
|
+
|
1432
|
+
|
1433
|
+
Selects how the query words are interpreted. It can be one of the following values:
|
1434
|
+
* `prefixAll`:
|
1435
|
+
All query words are interpreted as prefixes. This option is not recommended.
|
1436
|
+
* `prefixLast`:
|
1437
|
+
Only the last word is interpreted as a prefix (default behavior).
|
1438
|
+
* `prefixNone`:
|
1439
|
+
No query word is interpreted as a prefix. This option is not recommended.
|
1440
|
+
|
1441
|
+
#### removeWordsIfNoResults
|
1442
|
+
|
1443
|
+
- scope: `settings`, `search`
|
1444
|
+
- type: `string`
|
1445
|
+
- default: `'none'`
|
1446
|
+
|
1447
|
+
|
1448
|
+
This option is used to select a strategy in order to avoid having an empty result page.
|
1449
|
+
There are four different options:
|
1450
|
+
|
1451
|
+
- `lastWords`:
|
1452
|
+
When a query does not return any results, the last word will be added as optional.
|
1453
|
+
The process is repeated with n-1 word, n-2 word, ... until there are results.
|
1454
|
+
- `firstWords`:
|
1455
|
+
When a query does not return any results, the first word will be added as optional.
|
1456
|
+
The process is repeated with second word, third word, ... until there are results.
|
1457
|
+
- `allOptional`:
|
1458
|
+
When a query does not return any results, a second trial will be made with all words as optional.
|
1459
|
+
This is equivalent to transforming the AND operand between query terms to an OR operand.
|
1460
|
+
- `none`:
|
1461
|
+
No specific processing is done when a query does not return any results (default behavior).
|
1462
|
+
|
1463
|
+
|
1464
|
+
#### advancedSyntax
|
1465
|
+
|
1466
|
+
- scope: `settings`, `search`
|
1467
|
+
- type: `boolean`
|
1468
|
+
- default: `false`
|
1469
|
+
|
1470
|
+
|
1471
|
+
Enables the advanced query syntax.
|
1472
|
+
|
1473
|
+
This syntax allow to do two things:
|
1474
|
+
|
1475
|
+
* **Phrase query**: A phrase query defines a particular sequence of terms. A phrase query is built by Algolia's query parser for words surrounded by `"`. For example, `"search engine"` will retrieve records having `search` next to `engine` only. Typo tolerance is _disabled_ on phrase queries.
|
1476
|
+
* **Prohibit operator**: The prohibit operator excludes records that contain the term after the `-` symbol. For example, `search -engine` will retrieve records containing `search` but not `engine`.
|
1477
|
+
|
1478
|
+
|
1479
|
+
#### optionalWords
|
1480
|
+
|
1481
|
+
- scope: `settings`, `search`
|
1482
|
+
- type: `array of strings`
|
1483
|
+
- default: `[]`
|
1484
|
+
|
1485
|
+
|
1486
|
+
A string that contains the comma separated list of words that should be considered as optional when found in the query.
|
1487
|
+
|
1488
|
+
#### removeStopWords
|
1489
|
+
|
1490
|
+
- scope: `settings`, `search`
|
1491
|
+
- type: `boolean`, `array of strings`
|
1492
|
+
- default: `false`
|
1493
|
+
|
1494
|
+
|
1495
|
+
Remove stop words from the query **before** executing it. It can be:
|
1496
|
+
|
1497
|
+
- a **boolean**: enable or disable stop words for all 41 supported languages; or
|
1498
|
+
- a **list of language ISO codes** (as a comma-separated string) for which stop words should be enabled.
|
1499
|
+
|
1500
|
+
In most use-cases, **we don’t recommend enabling this option**.
|
1501
|
+
|
1502
|
+
List of 41 supported languages with their associated iso code: Arabic=`ar`, Armenian=`hy`, Basque=`eu`, Bengali=`bn`, Brazilian=`pt-br`, Bulgarian=`bg`, Catalan=`ca`, Chinese=`zh`, Czech=`cs`, Danish=`da`, Dutch=`nl`, English=`en`, Finnish=`fi`, French=`fr`, Galician=`gl`, German=`de`, Greek=`el`, Hindi=`hi`, Hungarian=`hu`, Indonesian=`id`, Irish=`ga`, Italian=`it`, Japanese=`ja`, Korean=`ko`, Kurdish=`ku`, Latvian=`lv`, Lithuanian=`lt`, Marathi=`mr`, Norwegian=`no`, Persian (Farsi)=`fa`, Polish=`pl`, Portugese=`pt`, Romanian=`ro`, Russian=`ru`, Slovak=`sk`, Spanish=`es`, Swedish=`sv`, Thai=`th`, Turkish=`tr`, Ukranian=`uk`, Urdu=`ur`.
|
1503
|
+
|
1504
|
+
Stop words removal is applied on query words that are not interpreted as a prefix. The behavior depends of the `queryType` parameter:
|
1505
|
+
|
1506
|
+
* `queryType=prefixLast` means the last query word is a prefix and it won’t be considered for stop words removal
|
1507
|
+
* `queryType=prefixNone` means no query word are prefix, stop words removal will be applied on all query words
|
1508
|
+
* `queryType=prefixAll` means all query terms are prefix, stop words won’t be removed
|
1509
|
+
|
1510
|
+
This parameter is useful when you have a query in natural language like “what is a record?”.
|
1511
|
+
In this case, before executing the query, we will remove “what”, “is” and “a” in order to just search for “record”.
|
1512
|
+
This removal will remove false positive because of stop words, especially when combined with optional words.
|
1513
|
+
For most use cases, it is better to not use this feature as people search by keywords on search engines.
|
1514
|
+
|
1515
|
+
|
1516
|
+
|
1517
|
+
|
1518
|
+
#### disablePrefixOnAttributes
|
1519
|
+
|
1520
|
+
- scope: `settings`
|
1521
|
+
- type: `array of strings`
|
1522
|
+
- default: `[]`
|
1523
|
+
|
1524
|
+
|
1525
|
+
List of attributes on which you want to disable prefix matching
|
1526
|
+
(must be a subset of the `attributesToIndex` index setting).
|
1527
|
+
|
1528
|
+
This setting is useful on attributes that contain string that should not be matched as a prefix
|
1529
|
+
(for example a product SKU).
|
1530
|
+
|
1531
|
+
|
1532
|
+
#### disableExactOnAttributes
|
1533
|
+
|
1534
|
+
- scope: `settings`, `search`
|
1535
|
+
- type: `array of strings`
|
1536
|
+
- default: `[]`
|
1537
|
+
|
1538
|
+
|
1539
|
+
List of attributes on which you want to disable the computation of `exact` criteria
|
1540
|
+
(must be a subset of the `attributesToIndex` index setting).
|
1541
|
+
|
1542
|
+
#### exactOnSingleWordQuery
|
1543
|
+
|
1544
|
+
- scope: `settings`, `search`
|
1545
|
+
- type: `string`
|
1546
|
+
- default: `attribute`
|
1547
|
+
|
1548
|
+
|
1549
|
+
This parameter control how the `exact` ranking criterion is computed when the query contains one word. There are three different values:
|
1550
|
+
|
1551
|
+
* `none`: no exact on single word query
|
1552
|
+
* `word`: exact set to 1 if the query word is found in the record. The query word needs to have at least 3 chars and not be part of our stop words dictionary
|
1553
|
+
* `attribute` (default): exact set to 1 if there is an attribute containing a string equals to the query
|
1554
|
+
|
1555
|
+
#### alternativesAsExact
|
1556
|
+
|
1557
|
+
- scope: `settings`, `search`
|
1558
|
+
- type: `string`
|
1559
|
+
- default: `['ignorePlurals', 'singleWordSynonym']`
|
1560
|
+
|
1561
|
+
|
1562
|
+
Specify the list of approximation that should be considered as an exact match in the ranking formula:
|
1563
|
+
|
1564
|
+
* `ignorePlurals`: alternative words added by the ignorePlurals feature
|
1565
|
+
* `singleWordSynonym`: single-word synonym (For example "NY" = "NYC")
|
1566
|
+
* `multiWordsSynonym`: multiple-words synonym (For example "NY" = "New York")
|
1567
|
+
|
1568
|
+
### Advanced
|
1569
|
+
|
1570
|
+
#### attributeForDistinct
|
1571
|
+
|
1572
|
+
- scope: `settings`
|
1573
|
+
- type: `string`
|
1574
|
+
- default: `null`
|
1575
|
+
|
1576
|
+
|
1577
|
+
The name of the attribute used for the `Distinct` feature.
|
1578
|
+
|
1579
|
+
This feature is similar to the SQL "distinct" keyword.
|
1580
|
+
When enabled in queries with the `distinct=1` parameter,
|
1581
|
+
all hits containing a duplicate value for this attribute are removed from the results.
|
1582
|
+
|
1583
|
+
For example, if the chosen attribute is `show_name` and several hits have the same value for `show_name`,
|
1584
|
+
then only the first one is kept and the others are removed from the results.
|
1585
|
+
|
1586
|
+
To get a full understanding of how `Distinct` works,
|
1587
|
+
you can have a look at our [guide on distinct](https://www.algolia.com/doc/search/distinct).
|
1588
|
+
|
1589
|
+
#### distinct
|
1590
|
+
|
1591
|
+
- scope: `settings`, `search`
|
1592
|
+
- type: `integer`
|
1593
|
+
- default: `0`
|
1594
|
+
|
1595
|
+
|
1596
|
+
If set to 1,
|
1597
|
+
enables the distinct feature, disabled by default, if the `attributeForDistinct` index setting is set.
|
1598
|
+
|
1599
|
+
This feature is similar to the SQL "distinct" keyword.
|
1600
|
+
When enabled in a query with the `distinct=1` parameter,
|
1601
|
+
all hits containing a duplicate value for the attributeForDistinct attribute are removed from results.
|
1602
|
+
|
1603
|
+
For example, if the chosen attribute is `show_name` and several hits have the same value for `show_name`,
|
1604
|
+
then only the best one is kept and the others are removed.
|
1605
|
+
|
1606
|
+
To get a full understanding of how `Distinct` works,
|
1607
|
+
you can have a look at our [guide on distinct](https://www.algolia.com/doc/search/distinct).
|
1608
|
+
|
1609
|
+
|
1610
|
+
#### getRankingInfo
|
1611
|
+
|
1612
|
+
- scope: `search`
|
1613
|
+
- type: `boolean`
|
1614
|
+
- default: `false`
|
1615
|
+
|
1616
|
+
|
1617
|
+
If set to true,
|
1618
|
+
the result hits will contain ranking information in the **_rankingInfo** attribute.
|
1619
|
+
|
1620
|
+
#### numericAttributesToIndex
|
1621
|
+
|
1622
|
+
- scope: `settings`
|
1623
|
+
- type: `array of strings`
|
1624
|
+
- default: ``
|
1625
|
+
|
1626
|
+
|
1627
|
+
All numerical attributes are automatically indexed as numerical filters
|
1628
|
+
(allowing filtering operations like `<` and `<=`).
|
1629
|
+
If you don't need filtering on some of your numerical attributes,
|
1630
|
+
you can specify this list to speed up the indexing.
|
1631
|
+
|
1632
|
+
If you only need to filter on a numeric value with the `=` operator,
|
1633
|
+
you can speed up the indexing by specifying the attribute with `equalOnly(AttributeName)`.
|
1634
|
+
The other operators will be disabled.
|
1635
|
+
|
1636
|
+
#### allowCompressionOfIntegerArray
|
1637
|
+
|
1638
|
+
- scope: `settings`
|
1639
|
+
- type: `boolean`
|
1640
|
+
- default: `false`
|
1641
|
+
|
1642
|
+
|
1643
|
+
Allows compression of big integer arrays.
|
1644
|
+
|
1645
|
+
In data-intensive use-cases,
|
1646
|
+
we recommended enabling this feature and then storing the list of user IDs or rights as an integer array.
|
1647
|
+
When enabled, the integer array is reordered to reach a better compression ratio.
|
1648
|
+
|
1649
|
+
#### numericFilters (deprecated)
|
1650
|
+
|
1651
|
+
- scope: `search`
|
1652
|
+
- type: `array of strings`
|
1653
|
+
- default: `[]`
|
1654
|
+
|
1655
|
+
|
1656
|
+
*This parameter is deprecated. Please use [filters](#filters) instead.*
|
1657
|
+
|
1658
|
+
A string that contains the comma separated list of numeric filters you want to apply.
|
1659
|
+
The filter syntax is `attributeName` followed by `operand` followed by `value`.
|
1660
|
+
Supported operands are `<`, `<=`, `=`, `>` and `>=`.
|
1661
|
+
|
1662
|
+
You can easily perform range queries via the `:` operator.
|
1663
|
+
This is equivalent to combining a `>=` and `<=` operand.
|
1664
|
+
|
1665
|
+
For example, `numericFilters=price:10 to 1000`.
|
1666
|
+
|
1667
|
+
You can also mix OR and AND operators.
|
1668
|
+
The OR operator is defined with a parenthesis syntax.
|
1669
|
+
|
1670
|
+
For example, `(code=1 AND (price:[0-100] OR price:[1000-2000]))`
|
1671
|
+
translates to `encodeURIComponent("code=1,(price:0 to 100,price:1000 to 2000)")`.
|
1672
|
+
|
1673
|
+
You can also use a string array encoding (for example `numericFilters: ["price>100","price<1000"]`).
|
1674
|
+
|
1675
|
+
#### tagFilters (deprecated)
|
1676
|
+
|
1677
|
+
- scope: `search`
|
1678
|
+
- type: `string`
|
1679
|
+
- default: `""`
|
1680
|
+
|
1681
|
+
|
1682
|
+
*This parameter is deprecated. Please use [filters](#filters) instead.*
|
1683
|
+
|
1684
|
+
Filter the query by a set of tags.
|
1685
|
+
|
1686
|
+
You can AND tags by separating them with commas.
|
1687
|
+
To OR tags, you must add parentheses.
|
1688
|
+
|
1689
|
+
For example, `tagFilters=tag1,(tag2,tag3)` means *tag1 AND (tag2 OR tag3)*.
|
1690
|
+
|
1691
|
+
You can also use a string array encoding.
|
1692
|
+
|
1693
|
+
For example, `tagFilters: ["tag1",["tag2","tag3"]]` means *tag1 AND (tag2 OR tag3)*.
|
1694
|
+
|
1695
|
+
Negations are supported via the `-` operator, prefixing the value.
|
1696
|
+
|
1697
|
+
For example: `tagFilters=tag1,-tag2`.
|
1698
|
+
|
1699
|
+
At indexing, tags should be added in the **_tags** attribute of objects.
|
1700
|
+
|
1701
|
+
For example `{"_tags":["tag1","tag2"]}`.
|
1702
|
+
|
1703
|
+
#### facetFilters (deprecated)
|
1704
|
+
|
1705
|
+
- scope: `search`
|
1706
|
+
- type: `string`
|
1707
|
+
- default: `""`
|
1708
|
+
|
1709
|
+
|
1710
|
+
*This parameter is deprecated. Please use [filters](#filters) instead.*
|
1711
|
+
|
1712
|
+
Filter the query with a list of facets. Facets are separated by commas and is encoded as `attributeName:value`.
|
1713
|
+
To OR facets, you must add parentheses.
|
1714
|
+
|
1715
|
+
For example: `facetFilters=(category:Book,category:Movie),author:John%20Doe`.
|
1716
|
+
|
1717
|
+
You can also use a string array encoding.
|
1718
|
+
|
1719
|
+
For example, `[["category:Book","category:Movie"],"author:John%20Doe"]`.
|
1720
|
+
|
1721
|
+
#### analytics
|
1722
|
+
|
1723
|
+
- scope: `search`
|
1724
|
+
- type: `boolean`
|
1725
|
+
- default: `true`
|
1726
|
+
|
1727
|
+
|
1728
|
+
If set to false, this query will not be taken into account in the analytics feature.
|
1729
|
+
|
1730
|
+
#### placeholders
|
1731
|
+
|
1732
|
+
- scope: `settings`
|
1733
|
+
- type: `hash of array of words`
|
1734
|
+
- default: ``
|
1735
|
+
|
1736
|
+
|
1737
|
+
This is an advanced use-case to define a token substitutable by a list of words
|
1738
|
+
without having the original token searchable.
|
1739
|
+
|
1740
|
+
It is defined by a hash associating placeholders to lists of substitutable words.
|
1741
|
+
|
1742
|
+
For example, `"placeholders": { "<streetnumber>": ["1", "2", "3", ..., "9999"]}`
|
1743
|
+
would allow it to be able to match all street numbers. We use the `< >` tag syntax
|
1744
|
+
to define placeholders in an attribute.
|
1745
|
+
|
1746
|
+
For example:
|
1747
|
+
|
1748
|
+
* Push a record with the placeholder:
|
1749
|
+
`{ "name" : "Apple Store", "address" : "<streetnumber> Opera street, Paris" }`.
|
1750
|
+
* Configure the placeholder in your index settings:
|
1751
|
+
`"placeholders": { "<streetnumber>" : ["1", "2", "3", "4", "5", ... ], ... }`.
|
1752
|
+
|
1753
|
+
#### altCorrections
|
1754
|
+
|
1755
|
+
- scope: `settings`
|
1756
|
+
- type: `array of objects`
|
1757
|
+
- default: `[]`
|
1758
|
+
|
1759
|
+
|
1760
|
+
Specify alternative corrections that you want to consider.
|
1761
|
+
|
1762
|
+
Each alternative correction is described by an object containing three attributes:
|
1763
|
+
|
1764
|
+
* `word` (string): The word to correct.
|
1765
|
+
* `correction` (string): The corrected word.
|
1766
|
+
* `nbTypos` (integer): The number of typos (1 or 2) that will be considered for the ranking algorithm (1 typo is better than 2 typos).
|
1767
|
+
|
1768
|
+
For example:
|
1769
|
+
|
1770
|
+
```
|
1771
|
+
"altCorrections": [
|
1772
|
+
{ "word" : "foot", "correction": "feet", "nbTypos": 1 },
|
1773
|
+
{ "word": "feet", "correction": "foot", "nbTypos": 1 }
|
1774
|
+
]
|
1775
|
+
```
|
1776
|
+
|
1777
|
+
|
1778
|
+
## Manage Indices
|
1779
|
+
|
1780
|
+
|
1781
|
+
|
1782
|
+
### Create an index
|
1783
|
+
|
1784
|
+
To create an index, you need to perform any indexing operation like:
|
1785
|
+
- set settings
|
1786
|
+
- add object
|
1787
|
+
|
1788
|
+
### List indices - `list_indexes`
|
1789
|
+
|
1790
|
+
You can list all your indices along with their associated information (number of entries, disk size, etc.) with the `list_indexes` method:
|
1791
|
+
|
1792
|
+
```ruby
|
1793
|
+
Algolia.list_indexes
|
1794
|
+
```
|
1522
1795
|
|
1523
|
-
</td>
|
1524
|
-
</tr>
|
1525
|
-
|
1526
|
-
|
1527
|
-
<tr>
|
1528
|
-
<td valign='top'>
|
1529
|
-
<div class='client-readme-param-container'>
|
1530
|
-
<div class='client-readme-param-container-inner'>
|
1531
|
-
<div class='client-readme-param-name'><code>disableTypoToleranceOnAttributes</code></div>
|
1532
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string array</strong></em></div></div>
|
1533
|
-
</div>
|
1534
|
-
</div>
|
1535
|
-
</td>
|
1536
|
-
<td class='client-readme-param-content'>
|
1537
|
-
<p>List of attributes on which you want to disable typo tolerance (must be a subset of the <code>attributesToIndex</code> index setting). By default the list is empty.</p>
|
1538
1796
|
|
1539
|
-
</td>
|
1540
|
-
</tr>
|
1541
|
-
|
1542
|
-
|
1543
|
-
<tr>
|
1544
|
-
<td valign='top'>
|
1545
|
-
<div class='client-readme-param-container'>
|
1546
|
-
<div class='client-readme-param-container-inner'>
|
1547
|
-
<div class='client-readme-param-name'><code>disablePrefixOnAttributes</code></div>
|
1548
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string array</strong></em></div></div>
|
1549
|
-
</div>
|
1550
|
-
</div>
|
1551
|
-
</td>
|
1552
|
-
<td class='client-readme-param-content'>
|
1553
|
-
<p>List of attributes on which you want to disable prefix matching (must be a subset of the <code>attributesToIndex</code> index setting). This setting is useful on attributes that contain string that should not be matched as a prefix (for example a product SKU). By default the list is empty.</p>
|
1554
1797
|
|
1555
|
-
</td>
|
1556
|
-
</tr>
|
1557
|
-
|
1558
|
-
|
1559
|
-
<tr>
|
1560
|
-
<td valign='top'>
|
1561
|
-
<div class='client-readme-param-container'>
|
1562
|
-
<div class='client-readme-param-container-inner'>
|
1563
|
-
<div class='client-readme-param-name'><code>disableExactOnAttributes</code></div>
|
1564
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string array</strong></em></div></div>
|
1565
|
-
</div>
|
1566
|
-
</div>
|
1567
|
-
</td>
|
1568
|
-
<td class='client-readme-param-content'>
|
1569
|
-
<p>List of attributes on which you want to disable the computation of <code>exact</code> criteria (must be a subset of the <code>attributesToIndex</code> index setting). By default the list is empty.</p>
|
1570
1798
|
|
1571
|
-
|
1572
|
-
</tr>
|
1573
|
-
|
1574
|
-
|
1575
|
-
<tr>
|
1576
|
-
<td valign='top'>
|
1577
|
-
<div class='client-readme-param-container'>
|
1578
|
-
<div class='client-readme-param-container-inner'>
|
1579
|
-
<div class='client-readme-param-name'><code>altCorrections</code></div>
|
1580
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>object array</strong></em></div></div>
|
1581
|
-
</div>
|
1582
|
-
</div>
|
1583
|
-
</td>
|
1584
|
-
<td class='client-readme-param-content'>
|
1585
|
-
<p>Specify alternative corrections that you want to consider. Each alternative correction is described by an object containing three attributes:</p>
|
1799
|
+
### Delete index - `delete_index`
|
1586
1800
|
|
1587
|
-
|
1588
|
-
<li><strong>word</strong>: The word to correct.</li>
|
1589
|
-
<li><strong>correction</strong>: The corrected word.</li>
|
1590
|
-
<li><strong>nbTypos</strong> The number of typos (1 or 2) that will be considered for the ranking algorithm (1 typo is better than 2 typos).</li>
|
1591
|
-
</ul>
|
1801
|
+
You can delete an index using its name:
|
1592
1802
|
|
1593
|
-
|
1803
|
+
```ruby
|
1804
|
+
index = Algolia::Index.new("contacts")
|
1805
|
+
index.delete_index
|
1806
|
+
```
|
1594
1807
|
|
1595
|
-
</td>
|
1596
|
-
</tr>
|
1597
|
-
|
1598
1808
|
|
1599
|
-
|
1809
|
+
### Clear index - `clear_index`
|
1600
1810
|
|
1601
|
-
|
1811
|
+
You can delete the index contents without removing settings and index specific API keys by using the `clearIndex` command:
|
1602
1812
|
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
<td valign='top'>
|
1607
|
-
<div class='client-readme-param-container'>
|
1608
|
-
<div class='client-readme-param-container-inner'>
|
1609
|
-
<div class='client-readme-param-name'><code>minWordSizefor1Typo</code></div>
|
1610
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer</strong></em></div><div><em>Default: <strong>4</strong></em></div></div>
|
1611
|
-
</div>
|
1612
|
-
</div>
|
1613
|
-
</td>
|
1614
|
-
<td class='client-readme-param-content'>
|
1615
|
-
<p>The minimum number of characters needed to accept one typo (default = 4).</p>
|
1813
|
+
```ruby
|
1814
|
+
index.clear_index
|
1815
|
+
```
|
1616
1816
|
|
1617
|
-
</td>
|
1618
|
-
</tr>
|
1619
|
-
|
1620
|
-
|
1621
|
-
<tr>
|
1622
|
-
<td valign='top'>
|
1623
|
-
<div class='client-readme-param-container'>
|
1624
|
-
<div class='client-readme-param-container-inner'>
|
1625
|
-
<div class='client-readme-param-name'><code>minWordSizefor2Typos</code></div>
|
1626
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer</strong></em></div><div><em>Default: <strong>8</strong></em></div></div>
|
1627
|
-
</div>
|
1628
|
-
</div>
|
1629
|
-
</td>
|
1630
|
-
<td class='client-readme-param-content'>
|
1631
|
-
<p>The minimum number of characters needed to accept two typos (default = 8).</p>
|
1632
1817
|
|
1633
|
-
|
1634
|
-
</tr>
|
1635
|
-
|
1636
|
-
|
1637
|
-
<tr>
|
1638
|
-
<td valign='top'>
|
1639
|
-
<div class='client-readme-param-container'>
|
1640
|
-
<div class='client-readme-param-container-inner'>
|
1641
|
-
<div class='client-readme-param-name'><code>hitsPerPage</code></div>
|
1642
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer</strong></em></div><div><em>Default: <strong>10</strong></em></div></div>
|
1643
|
-
</div>
|
1644
|
-
</div>
|
1645
|
-
</td>
|
1646
|
-
<td class='client-readme-param-content'>
|
1647
|
-
<p>The number of hits per page (default = 10).</p>
|
1818
|
+
### Copy index - `copy_index`
|
1648
1819
|
|
1649
|
-
|
1650
|
-
</tr>
|
1651
|
-
|
1652
|
-
|
1653
|
-
<tr>
|
1654
|
-
<td valign='top'>
|
1655
|
-
<div class='client-readme-param-container'>
|
1656
|
-
<div class='client-readme-param-container-inner'>
|
1657
|
-
<div class='client-readme-param-name'><code>attributesToRetrieve</code></div>
|
1658
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1659
|
-
</div>
|
1660
|
-
</div>
|
1661
|
-
</td>
|
1662
|
-
<td class='client-readme-param-content'>
|
1663
|
-
<p>Default list of attributes to retrieve in objects. If set to null, all attributes are retrieved.</p>
|
1820
|
+
You can copy an existing index using the `copy` command.
|
1664
1821
|
|
1665
|
-
|
1666
|
-
</tr>
|
1667
|
-
|
1668
|
-
|
1669
|
-
<tr>
|
1670
|
-
<td valign='top'>
|
1671
|
-
<div class='client-readme-param-container'>
|
1672
|
-
<div class='client-readme-param-container-inner'>
|
1673
|
-
<div class='client-readme-param-name'><code>attributesToHighlight</code></div>
|
1674
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1675
|
-
</div>
|
1676
|
-
</div>
|
1677
|
-
</td>
|
1678
|
-
<td class='client-readme-param-content'>
|
1679
|
-
<p>Default list of attributes to highlight. If set to null, all indexed attributes are highlighted.</p>
|
1822
|
+
**Warning**: The copy command will overwrite the destination index.
|
1680
1823
|
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
<tr>
|
1686
|
-
<td valign='top'>
|
1687
|
-
<div class='client-readme-param-container'>
|
1688
|
-
<div class='client-readme-param-container-inner'>
|
1689
|
-
<div class='client-readme-param-name'><code>attributesToSnippet</code></div>
|
1690
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1691
|
-
</div>
|
1692
|
-
</div>
|
1693
|
-
</td>
|
1694
|
-
<td class='client-readme-param-content'>
|
1695
|
-
<p>Default list of attributes to snippet alongside the number of words to return (syntax is <code>attributeName:nbWords</code>).<br/>By default, no snippet is computed. If set to null, no snippet is computed.</p>
|
1824
|
+
```ruby
|
1825
|
+
# Copy MyIndex in MyIndexCopy
|
1826
|
+
puts Algolia.copy_index("MyIndex", "MyIndexCopy")
|
1827
|
+
```
|
1696
1828
|
|
1697
|
-
</td>
|
1698
|
-
</tr>
|
1699
|
-
|
1700
|
-
|
1701
|
-
<tr>
|
1702
|
-
<td valign='top'>
|
1703
|
-
<div class='client-readme-param-container'>
|
1704
|
-
<div class='client-readme-param-container-inner'>
|
1705
|
-
<div class='client-readme-param-name'><code>highlightPreTag</code></div>
|
1706
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div></div>
|
1707
|
-
</div>
|
1708
|
-
</div>
|
1709
|
-
</td>
|
1710
|
-
<td class='client-readme-param-content'>
|
1711
|
-
<p>Specify the string that is inserted before the highlighted parts in the query result (defaults to <code><em></code>).</p>
|
1712
1829
|
|
1713
|
-
|
1714
|
-
</tr>
|
1715
|
-
|
1716
|
-
|
1717
|
-
<tr>
|
1718
|
-
<td valign='top'>
|
1719
|
-
<div class='client-readme-param-container'>
|
1720
|
-
<div class='client-readme-param-container-inner'>
|
1721
|
-
<div class='client-readme-param-name'><code>highlightPostTag</code></div>
|
1722
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div></div>
|
1723
|
-
</div>
|
1724
|
-
</div>
|
1725
|
-
</td>
|
1726
|
-
<td class='client-readme-param-content'>
|
1727
|
-
<p>Specify the string that is inserted after the highlighted parts in the query result (defaults to <code></em></code>).</p>
|
1830
|
+
### Move index - `move_index`
|
1728
1831
|
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
<tr>
|
1734
|
-
<td valign='top'>
|
1735
|
-
<div class='client-readme-param-container'>
|
1736
|
-
<div class='client-readme-param-container-inner'>
|
1737
|
-
<div class='client-readme-param-name'><code>optionalWords</code></div>
|
1738
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>array of strings</strong></em></div></div>
|
1739
|
-
</div>
|
1740
|
-
</div>
|
1741
|
-
</td>
|
1742
|
-
<td class='client-readme-param-content'>
|
1743
|
-
<p>Specify a list of words that should be considered optional when found in the query.</p>
|
1832
|
+
In some cases, you may want to totally reindex all your data. In order to keep your existing service
|
1833
|
+
running while re-importing your data we recommend the usage of a temporary index plus an atomical
|
1834
|
+
move using the `move_index` method.
|
1744
1835
|
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
<tr>
|
1750
|
-
<td valign='top'>
|
1751
|
-
<div class='client-readme-param-container'>
|
1752
|
-
<div class='client-readme-param-container-inner'>
|
1753
|
-
<div class='client-readme-param-name'><code>allowTyposOnNumericTokens</code></div>
|
1754
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>boolean</strong></em></div><div><em>Default: <strong>false</strong></em></div></div>
|
1755
|
-
</div>
|
1756
|
-
</div>
|
1757
|
-
</td>
|
1758
|
-
<td class='client-readme-param-content'>
|
1759
|
-
<p>If set to false, disable typo-tolerance on numeric tokens (=numbers) in the query word. For example the query <code>"304"</code> will match with <code>"30450"</code>, but not with <code>"40450"</code> that would have been the case with typo-tolerance enabled. Can be very useful on serial numbers and zip codes searches. Defaults to false.</p>
|
1836
|
+
```ruby
|
1837
|
+
# Rename MyNewIndex in MyIndex (and overwrite it)
|
1838
|
+
puts Algolia.move_index("MyNewIndex", "MyIndex")
|
1839
|
+
```
|
1760
1840
|
|
1761
|
-
|
1762
|
-
</tr>
|
1763
|
-
|
1764
|
-
|
1765
|
-
<tr>
|
1766
|
-
<td valign='top'>
|
1767
|
-
<div class='client-readme-param-container'>
|
1768
|
-
<div class='client-readme-param-container-inner'>
|
1769
|
-
<div class='client-readme-param-name'><code>ignorePlurals</code></div>
|
1770
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>boolean</strong></em></div><div><em>Default: <strong>false</strong></em></div></div>
|
1771
|
-
</div>
|
1772
|
-
</div>
|
1773
|
-
</td>
|
1774
|
-
<td class='client-readme-param-content'>
|
1775
|
-
<p>If set to true, singular/plural forms won’t be considered as typos (for example car/cars and foot/feet will be considered as equivalent). Defaults to false.</p>
|
1841
|
+
**Note**:
|
1776
1842
|
|
1777
|
-
|
1778
|
-
</tr>
|
1779
|
-
|
1780
|
-
|
1781
|
-
<tr>
|
1782
|
-
<td valign='top'>
|
1783
|
-
<div class='client-readme-param-container'>
|
1784
|
-
<div class='client-readme-param-container-inner'>
|
1785
|
-
<div class='client-readme-param-name'><code>advancedSyntax</code></div>
|
1786
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer (0 or 1)</strong></em></div><div><em>Default: <strong>0</strong></em></div></div>
|
1787
|
-
</div>
|
1788
|
-
</div>
|
1789
|
-
</td>
|
1790
|
-
<td class='client-readme-param-content'>
|
1791
|
-
<p>Enable the advanced query syntax. Defaults to 0 (false).</p>
|
1843
|
+
The move_index method will overwrite the destination index, and delete the temporary index.
|
1792
1844
|
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1845
|
+
**Warning**
|
1846
|
+
|
1847
|
+
The move_index operation will override all settings of the destination,
|
1848
|
+
There is one exception for the [slaves](#slaves) parameter which is not impacted.
|
1849
|
+
|
1850
|
+
For example, if you want to fully update your index `MyIndex` every night, we recommend the following process:
|
1851
|
+
|
1852
|
+
1. Get settings and synonyms from the old index using [Get settings](#get-settings---get_settings)
|
1853
|
+
and [Get synonym](#get-synonym---get_synonym).
|
1854
|
+
1. Apply settings and synonyms to the temporary index `MyTmpIndex`, (this will create the `MyTmpIndex` index)
|
1855
|
+
using [Set settings](#set-settings---set_settings) and [Batch synonyms](#batch-synonyms---batch_synonyms)
|
1856
|
+
(make sure to remove the [slaves](#slaves) parameter from the settings if it exists).
|
1857
|
+
1. Import your records into a new index using [Add objects](#add-objects---add_objects).
|
1858
|
+
1. Atomically replace the index `MyIndex` with the content and settings of the index `MyTmpIndex`
|
1859
|
+
using the [Move index](#move-index---move_index) method.
|
1860
|
+
This will automatically override the old index without any downtime on the search.
|
1861
|
+
1. You'll end up with only one index called `MyIndex`, that contains the records and settings pushed to `MyTmpIndex`
|
1862
|
+
and the slave-indices that were initially attached to `MyIndex` will be in sync with the new data.
|
1797
1863
|
|
1798
|
-
</td>
|
1799
|
-
</tr>
|
1800
|
-
|
1801
|
-
|
1802
|
-
<tr>
|
1803
|
-
<td valign='top'>
|
1804
|
-
<div class='client-readme-param-container'>
|
1805
|
-
<div class='client-readme-param-container-inner'>
|
1806
|
-
<div class='client-readme-param-name'><code>replaceSynonymsInHighlight</code></div>
|
1807
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>boolean</strong></em></div><div><em>Default: <strong>true</strong></em></div></div>
|
1808
|
-
</div>
|
1809
|
-
</div>
|
1810
|
-
</td>
|
1811
|
-
<td class='client-readme-param-content'>
|
1812
|
-
<p>If set to false, words matched via synonyms expansion will not be replaced by the matched synonym in the highlighted result. Defaults to true.</p>
|
1813
1864
|
|
1814
|
-
</td>
|
1815
|
-
</tr>
|
1816
|
-
|
1817
|
-
|
1818
|
-
<tr>
|
1819
|
-
<td valign='top'>
|
1820
|
-
<div class='client-readme-param-container'>
|
1821
|
-
<div class='client-readme-param-container-inner'>
|
1822
|
-
<div class='client-readme-param-name'><code>maxValuesPerFacet</code></div>
|
1823
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer</strong></em></div></div>
|
1824
|
-
</div>
|
1825
|
-
</div>
|
1826
|
-
</td>
|
1827
|
-
<td class='client-readme-param-content'>
|
1828
|
-
<p>Limit the number of facet values returned for each facet. For example: <code>maxValuesPerFacet=10</code> will retrieve max 10 values per facet.</p>
|
1829
1865
|
|
1830
|
-
</td>
|
1831
|
-
</tr>
|
1832
|
-
|
1833
|
-
|
1834
|
-
<tr>
|
1835
|
-
<td valign='top'>
|
1836
|
-
<div class='client-readme-param-container'>
|
1837
|
-
<div class='client-readme-param-container-inner'>
|
1838
|
-
<div class='client-readme-param-name'><code>distinct</code></div>
|
1839
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>integer (0 or 1)</strong></em></div><div><em>Default: <strong>0</strong></em></div></div>
|
1840
|
-
</div>
|
1841
|
-
</div>
|
1842
|
-
</td>
|
1843
|
-
<td class='client-readme-param-content'>
|
1844
|
-
<p>Enable the distinct feature (disabled by default) if the <code>attributeForDistinct</code> index setting is set. This feature is similar to the SQL "distinct" keyword: when enabled in a query with the <code>distinct=1</code> parameter, all hits containing a duplicate value for the<code>attributeForDistinct</code> attribute are removed from results. For example, if the chosen attribute is <code>show_name</code> and several hits have the same value for <code>show_name</code>, then only the best one is kept and others are removed.</p>
|
1845
1866
|
|
1846
|
-
<p>To get a full understanding of how <code>Distinct</code> works, you can have a look at our <a href="https://www.algolia.com/doc/search/distinct">guide on distinct</a>.</p>
|
1847
1867
|
|
1848
|
-
</td>
|
1849
|
-
</tr>
|
1850
|
-
|
1851
|
-
|
1852
|
-
<tr>
|
1853
|
-
<td valign='top'>
|
1854
|
-
<div class='client-readme-param-container'>
|
1855
|
-
<div class='client-readme-param-container-inner'>
|
1856
|
-
<div class='client-readme-param-name'><code>typoTolerance</code></div>
|
1857
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div><div><em>Default: <strong>true</strong></em></div></div>
|
1858
|
-
</div>
|
1859
|
-
</div>
|
1860
|
-
</td>
|
1861
|
-
<td class='client-readme-param-content'>
|
1862
|
-
<p>This setting has four different options:</p>
|
1863
1868
|
|
1864
|
-
|
1865
|
-
<li><p><code>true:</code> activate the typo-tolerance (default value).</p></li>
|
1866
|
-
<li><p><code>false:</code> disable the typo-tolerance</p></li>
|
1867
|
-
<li><p><code>min:</code> keep only results with the lowest number of typos. For example if one result matches without typos, then all results with typos will be hidden.</p></li>
|
1868
|
-
<li><p><code>strict:</code> if there is a match without typo, then all results with 2 typos or more will be removed.</p></li>
|
1869
|
-
</ul>
|
1869
|
+
## Api Keys
|
1870
1870
|
|
1871
|
-
|
1872
|
-
</tr>
|
1873
|
-
|
1874
|
-
|
1875
|
-
<tr>
|
1876
|
-
<td valign='top'>
|
1877
|
-
<div class='client-readme-param-container'>
|
1878
|
-
<div class='client-readme-param-container-inner'>
|
1879
|
-
<div class='client-readme-param-name'><code>removeStopWords</code></div>
|
1880
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>boolean or string array</strong></em></div><div><em>Default: <strong>false</strong></em></div></div>
|
1881
|
-
</div>
|
1882
|
-
</div>
|
1883
|
-
</td>
|
1884
|
-
<td class='client-readme-param-content'>
|
1885
|
-
<p>Remove stop words from the query <strong>before</strong> executing it. Defaults to <code>false</code>. Use a boolean to enable/disable all 41 supported languages and an array of string listing the iso codes of the languages you want to use consider to enable the stop words removal on a subset of them (select the one you have in your records).</p>
|
1871
|
+
The **admin** API key provides full control of all your indices. *The admin API key should always be kept secure; do NOT use it from outside your back-end.*
|
1886
1872
|
|
1887
|
-
|
1873
|
+
You can also generate user API keys to control security.
|
1874
|
+
These API keys can be restricted to a set of operations or/and restricted to a given index.
|
1888
1875
|
|
1889
|
-
|
1876
|
+
### Generate key - `generate_secured_api_key`
|
1890
1877
|
|
1891
|
-
|
1892
|
-
<li><p><code>queryType=prefixLast</code> means the last query word is a prefix and it won’t be considered for stop words removal</p></li>
|
1893
|
-
<li><p><code>queryType=prefixNone</code> means no query word are prefix, stop words removal will be applied on all query words</p></li>
|
1894
|
-
<li><p><code>queryType=prefixAll</code> means all query terms are prefix, stop words won’t be removed</p></li>
|
1895
|
-
</ul>
|
1878
|
+
You may have a single index containing **per user** data. In that case, all records should be tagged with their associated `user_id` in order to add a `tagFilters=user_42` filter at query time to retrieve only what a user has access to. If you're using the [JavaScript client](http://github.com/algolia/algoliasearch-client-js), it will result in a security breach since the user is able to modify the `tagFilters` you've set by modifying the code from the browser. To keep using the JavaScript client (recommended for optimal latency) and target secured records, you can generate a secured API key from your backend:
|
1896
1879
|
|
1897
|
-
|
1880
|
+
```ruby
|
1881
|
+
# generate a public API key for user 42. Here, records are tagged with:
|
1882
|
+
# - 'user_XXXX' if they are visible by user XXXX
|
1883
|
+
public_key = Algolia.generate_secured_api_key 'YourSearchOnlyApiKey', {'filters'=> '_tags:user_42'}
|
1884
|
+
```
|
1898
1885
|
|
1899
|
-
|
1900
|
-
</tr>
|
1901
|
-
|
1902
|
-
|
1903
|
-
<tr>
|
1904
|
-
<td valign='top'>
|
1905
|
-
<div class='client-readme-param-container'>
|
1906
|
-
<div class='client-readme-param-container-inner'>
|
1907
|
-
<div class='client-readme-param-name'><code>exactOnSingleWordQuery</code></div>
|
1908
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string</strong></em></div><div><em>Default: <strong>attribute</strong></em></div></div>
|
1909
|
-
</div>
|
1910
|
-
</div>
|
1911
|
-
</td>
|
1912
|
-
<td class='client-readme-param-content'>
|
1913
|
-
<p>This parameter controls how the <code>exact</code> ranking criterion is computed when the query contains one word. There is three different values:</p>
|
1886
|
+
This public API key can then be used in your JavaScript code as follow:
|
1914
1887
|
|
1915
|
-
|
1916
|
-
|
1917
|
-
<li><p><code>word</code>: <code>exact</code> set to 1 if the query word is found in the record. The query word needs to have at least 3 chars and not be part of our stop words dictionary</p></li>
|
1918
|
-
<li><p><code>attribute</code> (default): exact set to 1 if there is an attribute containing a string equals to the query</p></li>
|
1919
|
-
</ul>
|
1888
|
+
```js
|
1889
|
+
var client = algoliasearch('YourApplicationID', '<%= public_api_key %>');
|
1920
1890
|
|
1921
|
-
|
1922
|
-
</tr>
|
1923
|
-
|
1924
|
-
|
1925
|
-
<tr>
|
1926
|
-
<td valign='top'>
|
1927
|
-
<div class='client-readme-param-container'>
|
1928
|
-
<div class='client-readme-param-container-inner'>
|
1929
|
-
<div class='client-readme-param-name'><code>alternativesAsExact</code></div>
|
1930
|
-
<div class="client-readme-param-meta"><div><em>Type: <strong>string array</strong></em></div><div><em>Default: <strong>["ignorePlurals", "singleWordSynonym"]</strong></em></div></div>
|
1931
|
-
</div>
|
1932
|
-
</div>
|
1933
|
-
</td>
|
1934
|
-
<td class='client-readme-param-content'>
|
1935
|
-
<p>Specify the list of approximation that should be considered as an exact match in the ranking formula:</p>
|
1891
|
+
var index = client.initIndex('indexName')
|
1936
1892
|
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1893
|
+
index.search('something', function(err, content) {
|
1894
|
+
if (err) {
|
1895
|
+
console.error(err);
|
1896
|
+
return;
|
1897
|
+
}
|
1942
1898
|
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
</tbody></table>
|
1899
|
+
console.log(content);
|
1900
|
+
});
|
1901
|
+
```
|
1947
1902
|
|
1903
|
+
You can mix rate limits and secured API keys by setting a `userToken` query parameter at API key generation time. When set, a unique user will be identified by her `IP + user_token` instead of only by her `IP`. This allows you to restrict a single user to performing a maximum of `N` API calls per hour, even if she shares her `IP` with another user.
|
1948
1904
|
|
1905
|
+
```ruby
|
1906
|
+
# generate a public API key for user 42. Here, records are tagged with:
|
1907
|
+
# - 'user_XXXX' if they are visible by user XXXX
|
1908
|
+
public_key = Algolia.generate_secured_api_key 'YourSearchOnlyApiKey', {'filters'=> '_tags:user_42', 'userToken'=> 'user_42'}
|
1909
|
+
```
|
1949
1910
|
|
1911
|
+
This public API key can then be used in your JavaScript code as follow:
|
1950
1912
|
|
1951
|
-
|
1952
|
-
|
1953
|
-
You can list all your indices along with their associated information (number of entries, disk size, etc.) with the `list_indexes` method:
|
1913
|
+
```js
|
1914
|
+
var client = algoliasearch('YourApplicationID', '<%= public_api_key %>');
|
1954
1915
|
|
1955
|
-
|
1956
|
-
|
1916
|
+
var index = client.initIndex('indexName')
|
1917
|
+
|
1918
|
+
index.search('another query', function(err, content) {
|
1919
|
+
if (err) {
|
1920
|
+
console.error(err);
|
1921
|
+
return;
|
1922
|
+
}
|
1923
|
+
|
1924
|
+
console.log(content);
|
1925
|
+
});
|
1957
1926
|
```
|
1958
1927
|
|
1959
1928
|
|
1960
1929
|
|
1961
1930
|
|
1962
1931
|
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1932
|
+
## Synonyms
|
1933
|
+
|
1934
|
+
### Save synonym - `save_synonym`
|
1935
|
+
|
1936
|
+
This method saves a single synonym record into the index.
|
1937
|
+
|
1938
|
+
In this example, we specify true to forward the creation to slave indices.
|
1939
|
+
By default the behavior is to save only on the specified index.
|
1966
1940
|
|
1967
1941
|
```ruby
|
1968
|
-
index
|
1969
|
-
|
1942
|
+
index.save_synonym('a-unique-identifier', {
|
1943
|
+
:objectID => 'a-unique-identifier',
|
1944
|
+
:type => 'synonym',
|
1945
|
+
:synonyms => ['car', 'vehicle', 'auto']
|
1946
|
+
}, true)
|
1970
1947
|
```
|
1971
1948
|
|
1949
|
+
### Batch synonyms - `batch_synonyms`
|
1950
|
+
|
1951
|
+
Use the batch method to create a large number of synonyms at once,
|
1952
|
+
forward them to slave indices if desired,
|
1953
|
+
and optionally replace all existing synonyms
|
1954
|
+
on the index with the content of the batch using the replaceExistingSynonyms parameter.
|
1955
|
+
|
1956
|
+
You should always use replaceExistingSynonyms to atomically replace all synonyms
|
1957
|
+
on a production index. This is the only way to ensure the index always
|
1958
|
+
has a full list of synonyms to use during the indexing of the new list.
|
1959
|
+
|
1960
|
+
```ruby
|
1961
|
+
# Batch synonyms, with slave forwarding and atomic replacement of existing synonyms
|
1962
|
+
index.batch_synonyms([{
|
1963
|
+
:objectID => 'a-unique-identifier',
|
1964
|
+
:type => 'synonym',
|
1965
|
+
:synonyms => ['car', 'vehicle', 'auto']
|
1966
|
+
}, {
|
1967
|
+
:objectID => 'another-unique-identifier',
|
1968
|
+
:type => 'synonym',
|
1969
|
+
:synonyms => ['street', 'st']
|
1970
|
+
}], true, true)
|
1971
|
+
```
|
1972
1972
|
|
1973
|
+
### Editing Synonyms
|
1973
1974
|
|
1975
|
+
Updating the value of a specific synonym record is the same as creating one.
|
1976
|
+
Make sure you specify the same objectID used to create the record and the synonyms
|
1977
|
+
will be updated.
|
1978
|
+
When updating multiple synonyms in a batch call (but not all synonyms),
|
1979
|
+
make sure you set replaceExistingSynonyms to false (or leave it out,
|
1980
|
+
false is the default value).
|
1981
|
+
Otherwise, the entire synonym list will be replaced only partially with the records
|
1982
|
+
in the batch update.
|
1974
1983
|
|
1984
|
+
### Delete Synonyms - `delete_synonyms`
|
1975
1985
|
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1986
|
+
Use the normal index delete method to delete synonyms,
|
1987
|
+
specifying the objectID of the synonym record you want to delete.
|
1988
|
+
Forward the deletion to slave indices by setting the forwardToSlaves parameter to true.
|
1979
1989
|
|
1980
1990
|
```ruby
|
1981
|
-
|
1991
|
+
# Delete and forward to slaves
|
1992
|
+
index.delete_synonym('a-unique-identifier', true)
|
1982
1993
|
```
|
1983
1994
|
|
1984
|
-
|
1985
|
-
==================
|
1995
|
+
### Clear all synonyms - `clear_synonyms`
|
1986
1996
|
|
1987
|
-
|
1997
|
+
This is a convenience method to delete all synonyms at once.
|
1998
|
+
It should not be used on a production index to then push a new list of synonyms:
|
1999
|
+
there would be a short period of time during which the index would have no synonyms
|
2000
|
+
at all.
|
1988
2001
|
|
1989
|
-
|
1990
|
-
|
1991
|
-
operation.
|
2002
|
+
To atomically replace all synonyms of an index,
|
2003
|
+
use the batch method with the replaceExistingSynonyms parameter set to true.
|
1992
2004
|
|
1993
|
-
|
2005
|
+
```ruby
|
2006
|
+
# Clear synonyms and forward to slaves
|
2007
|
+
index.clear_synonyms(true)
|
2008
|
+
```
|
1994
2009
|
|
1995
|
-
|
2010
|
+
### Get synonym - `get_synonym`
|
2011
|
+
|
2012
|
+
Search for synonym records by their objectID or by the text they contain.
|
2013
|
+
Both methods are covered here.
|
1996
2014
|
|
1997
|
-
For example, to wait for indexing of a new object:
|
1998
2015
|
```ruby
|
1999
|
-
|
2000
|
-
"lastname" => "Barninger"})
|
2016
|
+
synonym = index.get_synonym('a-unique-identifier')
|
2001
2017
|
```
|
2002
2018
|
|
2003
|
-
|
2004
|
-
the biggest `taskID` with `wait_task`.
|
2019
|
+
### Search synonyms - `search_synonyms`
|
2005
2020
|
|
2006
|
-
|
2007
|
-
|
2021
|
+
Search for synonym records similar to how you’d search normally.
|
2022
|
+
|
2023
|
+
Accepted search parameters:
|
2024
|
+
- query: the actual search query to find synonyms. Use an empty query to browse all the synonyms of an index.
|
2025
|
+
- type: restrict the search to a specific type of synonym. Use an empty string to search all types (default behavior). Multiple types can be specified using a comma-separated list or an array.
|
2026
|
+
- page: the page to fetch when browsing through several pages of results. This value is zero-based.
|
2027
|
+
hitsPerPage: the number of synonyms to return for each call. The default value is 100.
|
2028
|
+
|
2029
|
+
```ruby
|
2030
|
+
# Searching for "street" in synonyms and one-way synonyms; fetch the second page with 10 hits per page
|
2031
|
+
results = index.search_synonyms('street', {
|
2032
|
+
:type => ['synonym', 'oneWaySynonym'],
|
2033
|
+
:page => 1,
|
2034
|
+
:hitsPerPage => 10
|
2035
|
+
})
|
2036
|
+
```
|
2037
|
+
|
2038
|
+
|
2039
|
+
|
2040
|
+
## Advanced
|
2041
|
+
|
2042
|
+
### Custom batch - `batch`
|
2008
2043
|
|
2009
2044
|
You may want to perform multiple operations with one API call to reduce latency.
|
2010
2045
|
We expose four methods to perform batch operations:
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2046
|
+
|
2047
|
+
* Add objects - `add_objects`: Add an array of objects using automatic `objectID` assignment.
|
2048
|
+
* Update objects - `save_objects`: Add or update an array of objects that contains an `objectID` attribute.
|
2049
|
+
* Delete objects - `delete_objects`: Delete an array of objectIDs.
|
2050
|
+
* Partial update - `partial_update_objects`: Partially update an array of objects that contain an `objectID` attribute (only specified attributes will be updated).
|
2015
2051
|
|
2016
2052
|
Example using automatic `objectID` assignment:
|
2053
|
+
|
2017
2054
|
```ruby
|
2018
2055
|
res = index.add_objects([{"firstname" => "Jimmie",
|
2019
2056
|
"lastname" => "Barninger"},
|
@@ -2022,6 +2059,7 @@ res = index.add_objects([{"firstname" => "Jimmie",
|
|
2022
2059
|
```
|
2023
2060
|
|
2024
2061
|
Example with user defined `objectID` (add or update):
|
2062
|
+
|
2025
2063
|
```ruby
|
2026
2064
|
res = index.save_objects([{"firstname" => "Jimmie",
|
2027
2065
|
"lastname" => "Barninger",
|
@@ -2032,11 +2070,13 @@ res = index.save_objects([{"firstname" => "Jimmie",
|
|
2032
2070
|
```
|
2033
2071
|
|
2034
2072
|
Example that deletes a set of records:
|
2073
|
+
|
2035
2074
|
```ruby
|
2036
2075
|
res = index.delete_objects(["myID1", "myID2"])
|
2037
2076
|
```
|
2038
2077
|
|
2039
2078
|
Example that updates only the `firstname` attribute:
|
2079
|
+
|
2040
2080
|
```ruby
|
2041
2081
|
res = index.partial_update_objects([{"firstname" => "Jimmie",
|
2042
2082
|
"objectID" => "SFO"},
|
@@ -2048,6 +2088,7 @@ res = index.partial_update_objects([{"firstname" => "Jimmie",
|
|
2048
2088
|
|
2049
2089
|
If you have one index per user, you may want to perform a batch operations across severals indexes.
|
2050
2090
|
We expose a method to perform this type of batch:
|
2091
|
+
|
2051
2092
|
```ruby
|
2052
2093
|
res = index.batch([
|
2053
2094
|
{"action"=> "addObject", "indexName"=> "index1", "body": {"firstname" => "Jimmie",
|
@@ -2057,36 +2098,14 @@ res = index.batch([
|
|
2057
2098
|
```
|
2058
2099
|
|
2059
2100
|
The attribute **action** can have these values:
|
2101
|
+
|
2060
2102
|
- addObject
|
2061
2103
|
- updateObject
|
2062
2104
|
- partialUpdateObject
|
2063
2105
|
- partialUpdateObjectNoCreate
|
2064
2106
|
- deleteObject
|
2065
2107
|
|
2066
|
-
|
2067
|
-
==================
|
2068
|
-
|
2069
|
-
You can easily copy or rename an existing index using the `copy` and `move` commands.
|
2070
|
-
**Note**: Move and copy commands overwrite the destination index.
|
2071
|
-
|
2072
|
-
```ruby
|
2073
|
-
# Rename MyIndex in MyIndexNewName
|
2074
|
-
puts Algolia.move_index("MyIndex", "MyIndexNewName")
|
2075
|
-
# Copy MyIndex in MyIndexCopy
|
2076
|
-
puts Algolia.copy_index("MyIndex", "MyIndexCopy")
|
2077
|
-
```
|
2078
|
-
|
2079
|
-
The move command is particularly useful if you want to update a big index atomically from one version to another. For example, if you recreate your index `MyIndex` each night from a database by batch, you only need to:
|
2080
|
-
1. Import your database into a new index using [batches](#batch-writes). Let's call this new index `MyNewIndex`.
|
2081
|
-
1. Rename `MyNewIndex` to `MyIndex` using the move command. This will automatically override the old index and new queries will be served on the new one.
|
2082
|
-
|
2083
|
-
```ruby
|
2084
|
-
# Rename MyNewIndex in MyIndex (and overwrite it)
|
2085
|
-
puts Algolia.move_index("MyNewIndex", "MyIndex")
|
2086
|
-
```
|
2087
|
-
|
2088
|
-
Backup / Export an index
|
2089
|
-
==================
|
2108
|
+
### Backup / Export an index - `browse`
|
2090
2109
|
|
2091
2110
|
The `search` method cannot return more than 1,000 results. If you need to
|
2092
2111
|
retrieve all the content of your index (for backup, SEO purposes or for running
|
@@ -2098,7 +2117,48 @@ word proximity, geo distance and number of matched words are disabled. Results
|
|
2098
2117
|
are still returned ranked by attributes and custom ranking.
|
2099
2118
|
|
2100
2119
|
|
2101
|
-
|
2120
|
+
#### Response Format
|
2121
|
+
|
2122
|
+
##### Sample
|
2123
|
+
|
2124
|
+
```json
|
2125
|
+
{
|
2126
|
+
"hits": [
|
2127
|
+
{
|
2128
|
+
"firstname": "Jimmie",
|
2129
|
+
"lastname": "Barninger",
|
2130
|
+
"objectID": "433"
|
2131
|
+
}
|
2132
|
+
],
|
2133
|
+
"processingTimeMS": 7,
|
2134
|
+
"query": "",
|
2135
|
+
"params": "filters=level%3D20",
|
2136
|
+
"cursor": "ARJmaWx0ZXJzPWxldmVsJTNEMjABARoGODA4OTIzvwgAgICAgICAgICAAQ=="
|
2137
|
+
}
|
2138
|
+
```
|
2139
|
+
|
2140
|
+
##### Fields
|
2141
|
+
|
2142
|
+
- `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.
|
2143
|
+
|
2144
|
+
- `query` (string): Query text used to filter the results.
|
2145
|
+
|
2146
|
+
- `params` (string, URL-encoded): Search parameters used to filter the results.
|
2147
|
+
|
2148
|
+
- `processingTimeMS` (integer): Time that the server took to process the request, in milliseconds. *Note: This does not include network time.*
|
2149
|
+
|
2150
|
+
The following fields are provided for convenience purposes, and **only when the browse is not filtered**:
|
2151
|
+
|
2152
|
+
- `nbHits` (integer): Number of objects in the index.
|
2153
|
+
|
2154
|
+
- `page` (integer): Index of the current page (zero-based).
|
2155
|
+
|
2156
|
+
- `hitsPerPage` (integer): Maximum number of hits returned per page.
|
2157
|
+
|
2158
|
+
- `nbPages` (integer): Number of pages corresponding to the number of hits. Basically, `ceil(nbHits / hitsPerPage)`.
|
2159
|
+
|
2160
|
+
|
2161
|
+
#### Example
|
2102
2162
|
|
2103
2163
|
```ruby
|
2104
2164
|
# Iterate with a filter over the index
|
@@ -2110,16 +2170,7 @@ end
|
|
2110
2170
|
|
2111
2171
|
|
2112
2172
|
|
2113
|
-
|
2114
|
-
API Keys
|
2115
|
-
==================
|
2116
|
-
|
2117
|
-
The **admin** API key provides full control of all your indices. *The admin API key should always be kept secure; do NOT use it from outside your back-end.*
|
2118
|
-
|
2119
|
-
You can also generate user API keys to control security.
|
2120
|
-
These API keys can be restricted to a set of operations or/and restricted to a given index.
|
2121
|
-
|
2122
|
-
## List API keys
|
2173
|
+
### List api keys - `list_api_keys`
|
2123
2174
|
|
2124
2175
|
To list existing keys, you can use:
|
2125
2176
|
|
@@ -2131,17 +2182,18 @@ index.list_user_keys
|
|
2131
2182
|
```
|
2132
2183
|
|
2133
2184
|
Each key is defined by a set of permissions that specify the authorized actions. The different permissions are:
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2185
|
+
|
2186
|
+
* **search**: Allowed to search.
|
2187
|
+
* **browse**: Allowed to retrieve all index contents via the browse API.
|
2188
|
+
* **addObject**: Allowed to add/update an object in the index.
|
2189
|
+
* **deleteObject**: Allowed to delete an existing object.
|
2190
|
+
* **deleteIndex**: Allowed to delete index content.
|
2191
|
+
* **settings**: allows to get index settings.
|
2192
|
+
* **editSettings**: Allowed to change index settings.
|
2193
|
+
* **analytics**: Allowed to retrieve analytics through the analytics API.
|
2194
|
+
* **listIndexes**: Allowed to list all accessible indexes.
|
2195
|
+
|
2196
|
+
### Add user key - `add_user_key`
|
2145
2197
|
|
2146
2198
|
To create API keys:
|
2147
2199
|
|
@@ -2234,7 +2286,7 @@ You can also create an API Key with advanced settings:
|
|
2234
2286
|
</div>
|
2235
2287
|
</td>
|
2236
2288
|
<td class='client-readme-param-content'>
|
2237
|
-
<p>Specify the list of referers. You can target all referers starting with a prefix
|
2289
|
+
<p>Specify the list of referers. You can target all referers starting with a prefix, ending with a suffix using the '*' character. For example, "<a href="https://algolia.com/%5C*">https://algolia.com/\*</a>" matches all referers starting with "<a href="https://algolia.com/">https://algolia.com/</a>" and "*.algolia.com" matches all referers ending with ".algolia.com". If you want to allow the domain algolia.com you can use "*algolia.com/*". Defaults to all referers if empty or blank.</p>
|
2238
2290
|
|
2239
2291
|
</td>
|
2240
2292
|
</tr>
|
@@ -2298,9 +2350,10 @@ res = Algolia.add_user_key(params)
|
|
2298
2350
|
puts res['key']
|
2299
2351
|
```
|
2300
2352
|
|
2301
|
-
|
2353
|
+
### Update user key - `update_user_key`
|
2302
2354
|
|
2303
2355
|
To update the permissions of an existing key:
|
2356
|
+
|
2304
2357
|
```ruby
|
2305
2358
|
# Update an existing global API key that is valid for 300 seconds
|
2306
2359
|
res = Algolia.update_user_key("myAPIKey", ["search"], 300)
|
@@ -2313,7 +2366,9 @@ puts res['key']
|
|
2313
2366
|
res = index.update_user_key("myAPIKey", ["search"], 300, 100, 20, ['my_index1', 'my_index2'])
|
2314
2367
|
puts res['key']
|
2315
2368
|
```
|
2369
|
+
|
2316
2370
|
To get the permissions of a given key:
|
2371
|
+
|
2317
2372
|
```ruby
|
2318
2373
|
# Gets the rights of a global key
|
2319
2374
|
Algolia.get_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
@@ -2321,9 +2376,10 @@ Algolia.get_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
|
2321
2376
|
index.get_user_key("71671c38001bf3ac857bc82052485107")
|
2322
2377
|
```
|
2323
2378
|
|
2324
|
-
|
2379
|
+
### Delete user key - `delete_user_key`
|
2325
2380
|
|
2326
2381
|
To delete an existing key:
|
2382
|
+
|
2327
2383
|
```ruby
|
2328
2384
|
# Deletes a global key
|
2329
2385
|
Algolia.delete_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
@@ -2331,76 +2387,67 @@ Algolia.delete_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
|
2331
2387
|
index.delete_user_key("71671c38001bf3ac857bc82052485107")
|
2332
2388
|
```
|
2333
2389
|
|
2390
|
+
### Get key permissions - `get_user_key_acl`
|
2334
2391
|
|
2335
2392
|
|
2336
|
-
## Secured API keys (frontend)
|
2337
2393
|
|
2338
|
-
|
2394
|
+
To get the permissions of a given key:
|
2339
2395
|
|
2340
2396
|
```ruby
|
2341
|
-
#
|
2342
|
-
|
2343
|
-
|
2397
|
+
# Gets the rights of a global key
|
2398
|
+
Algolia.get_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
2399
|
+
# Gets the rights of an index specific key
|
2400
|
+
index.get_user_key("71671c38001bf3ac857bc82052485107")
|
2344
2401
|
```
|
2345
2402
|
|
2346
|
-
|
2347
|
-
|
2348
|
-
```js
|
2349
|
-
var client = algoliasearch('YourApplicationID', '<%= public_api_key %>');
|
2403
|
+
### Multiple queries - `multiple_queries`
|
2350
2404
|
|
2351
|
-
|
2405
|
+
You can send multiple queries with a single API call using a batch of queries:
|
2352
2406
|
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2407
|
+
```ruby
|
2408
|
+
# perform 3 queries in a single API call:
|
2409
|
+
# - 1st query targets index `categories`
|
2410
|
+
# - 2nd and 3rd queries target index `products`
|
2411
|
+
res = Algolia.multiple_queries([{:index_name => "categories", "query" => my_query_string, "hitsPerPage" => 3}
|
2412
|
+
, {:index_name => "products", "query" => my_query_string, "hitsPerPage" => 3, "filters" => "_tags:promotion"}
|
2413
|
+
, {:index_name => "products", "query" => my_query_string, "hitsPerPage" => 10}])
|
2358
2414
|
|
2359
|
-
|
2360
|
-
});
|
2415
|
+
puts res["results"]
|
2361
2416
|
```
|
2362
2417
|
|
2363
|
-
You can
|
2418
|
+
You can specify a `strategy` parameter to optimize your multiple queries:
|
2364
2419
|
|
2365
|
-
|
2366
|
-
|
2367
|
-
# - 'user_XXXX' if they are visible by user XXXX
|
2368
|
-
public_key = Algolia.generate_secured_api_key 'YourSearchOnlyApiKey', {'filters'=> '_tags:user_42', 'userToken'=> 'user_42'}
|
2369
|
-
```
|
2420
|
+
- `none`: Execute the sequence of queries until the end.
|
2421
|
+
- `stopIfEnoughMatches`: Execute the sequence of queries until the number of hits is reached by the sum of hits.
|
2370
2422
|
|
2371
|
-
|
2423
|
+
#### Response
|
2372
2424
|
|
2373
|
-
|
2374
|
-
var client = algoliasearch('YourApplicationID', '<%= public_api_key %>');
|
2425
|
+
The resulting JSON contains the following fields:
|
2375
2426
|
|
2376
|
-
|
2427
|
+
- `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---search).
|
2377
2428
|
|
2378
|
-
|
2379
|
-
if (err) {
|
2380
|
-
console.error(err);
|
2381
|
-
return;
|
2382
|
-
}
|
2429
|
+
Each result also includes the following additional fields:
|
2383
2430
|
|
2384
|
-
|
2385
|
-
});
|
2386
|
-
```
|
2431
|
+
- `index` (string): The name of the targeted index.
|
2387
2432
|
|
2433
|
+
- `processed` (boolean, optional): *Note: Only returned when `strategy` is `stopIfEnoughmatches`.* Whether the query was processed.
|
2388
2434
|
|
2389
2435
|
|
2390
2436
|
|
2391
|
-
|
2392
|
-
|
2437
|
+
|
2438
|
+
### Get Logs - `get_logs`
|
2393
2439
|
|
2394
2440
|
You can retrieve the latest logs via this API. Each log entry contains:
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2441
|
+
|
2442
|
+
* Timestamp in ISO-8601 format
|
2443
|
+
* Client IP
|
2444
|
+
* Request Headers (API Key is obfuscated)
|
2445
|
+
* Request URL
|
2446
|
+
* Request method
|
2447
|
+
* Request body
|
2448
|
+
* Answer HTTP code
|
2449
|
+
* Answer body
|
2450
|
+
* SHA1 ID of entry
|
2404
2451
|
|
2405
2452
|
You can retrieve the logs of your last 1,000 API calls and browse them using the offset/length parameters:
|
2406
2453
|
|
@@ -2486,8 +2533,24 @@ puts Algolia.get_logs(0, 100).to_json
|
|
2486
2533
|
puts Algolia.get_logs(0, 100, true).to_json
|
2487
2534
|
```
|
2488
2535
|
|
2489
|
-
|
2490
|
-
|
2536
|
+
|
2537
|
+
### REST API
|
2538
|
+
|
2539
|
+
We've developed API clients for the most common programming languages and platforms.
|
2540
|
+
These clients are advanced wrappers on top of our REST API itself and have been made
|
2541
|
+
in order to help you integrating the service within your apps:
|
2542
|
+
for both indexing and search.
|
2543
|
+
|
2544
|
+
Everything that can be done using the REST API can be done using those clients.
|
2545
|
+
|
2546
|
+
The REST API lets your interact directly with Algolia platforms from anything that can send an HTTP request
|
2547
|
+
[Go to the REST API doc](https://algolia.com/doc/rest)
|
2548
|
+
|
2549
|
+
|
2550
|
+
|
2551
|
+
## Mocking
|
2552
|
+
|
2553
|
+
### Webmock
|
2491
2554
|
|
2492
2555
|
For testing purposes, you may want to mock Algolia's API calls. We provide a [WebMock](https://github.com/bblimke/webmock) configuration that you can use including `algolia/webmock`:
|
2493
2556
|
|
@@ -2516,5 +2579,3 @@ end
|
|
2516
2579
|
```
|
2517
2580
|
|
2518
2581
|
|
2519
|
-
|
2520
|
-
|