algoliasearch 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/README.md +71 -59
- data/lib/algolia/client.rb +1 -1
- data/lib/algolia/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 249bdbdfe9306f6396363418d097060519a2b666
|
4
|
+
data.tar.gz: 29cd2a19ac2652eb9b19ec9a6e1a4e74aa9d6faf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5fdf482ba1c5734c95009719c836132b7e1e18d810a7959d6d48bd767669648e8d75221103f2080359cbe8d611c17575b42da65ddfc60b22ed76a1a0e88e4ce
|
7
|
+
data.tar.gz: c1ddb83fbc011fb659831ba67545d7ed2b65ed8d2320fc16f76749d46a097a7cc22b92e44908eff216d636ecdf3f0d49b3f43ac9178f72a65dc1d5b0eba03e35
|
data/ChangeLog
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
2016-04-14 1.8.1
|
4
|
+
* Ensure we're using an absolute path for the `ca-bundle.crt` file (could fix some `OpenSSL::X509::StoreError: system lib` errors)
|
5
|
+
|
3
6
|
2016-04-06 1.8.0
|
4
7
|
* Upgraded to httpclient 2.7.1 (includes ruby 2.3.0 deprecation fixes)
|
5
8
|
* Upgraded WebMock URLs
|
data/README.md
CHANGED
@@ -51,9 +51,9 @@ Table of Contents
|
|
51
51
|
1. [Clear an index](#clear-an-index)
|
52
52
|
1. [Wait indexing](#wait-indexing)
|
53
53
|
1. [Batch writes](#batch-writes)
|
54
|
-
1. [
|
55
|
-
1. [
|
56
|
-
1. [
|
54
|
+
1. [Copy / Move an index](#copy--move-an-index)
|
55
|
+
1. [Backup / Export an index](#backup--export-an-index)
|
56
|
+
1. [API Keys](#api-keys)
|
57
57
|
1. [Logs](#logs)
|
58
58
|
1. [Mock](#mock)
|
59
59
|
|
@@ -1907,14 +1907,65 @@ The attribute **action** can have these values:
|
|
1907
1907
|
- partialUpdateObjectNoCreate
|
1908
1908
|
- deleteObject
|
1909
1909
|
|
1910
|
-
|
1910
|
+
Copy / Move an index
|
1911
|
+
==================
|
1912
|
+
|
1913
|
+
You can easily copy or rename an existing index using the `copy` and `move` commands.
|
1914
|
+
**Note**: Move and copy commands overwrite the destination index.
|
1915
|
+
|
1916
|
+
```ruby
|
1917
|
+
# Rename MyIndex in MyIndexNewName
|
1918
|
+
puts Algolia.move_index("MyIndex", "MyIndexNewName")
|
1919
|
+
# Copy MyIndex in MyIndexCopy
|
1920
|
+
puts Algolia.copy_index("MyIndex", "MyIndexCopy")
|
1921
|
+
```
|
1922
|
+
|
1923
|
+
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:
|
1924
|
+
1. Import your database into a new index using [batches](#batch-writes). Let's call this new index `MyNewIndex`.
|
1925
|
+
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.
|
1926
|
+
|
1927
|
+
```ruby
|
1928
|
+
# Rename MyNewIndex in MyIndex (and overwrite it)
|
1929
|
+
puts Algolia.move_index("MyNewIndex", "MyIndex")
|
1930
|
+
```
|
1931
|
+
|
1932
|
+
|
1933
|
+
Backup / Export an index
|
1934
|
+
==================
|
1935
|
+
|
1936
|
+
The `search` method cannot return more than 1,000 results. If you need to
|
1937
|
+
retrieve all the content of your index (for backup, SEO purposes or for running
|
1938
|
+
a script on it), you should use the `browse` method instead. This method lets
|
1939
|
+
you retrieve objects beyond the 1,000 limit.
|
1940
|
+
|
1941
|
+
This method is optimized for speed. To make it fast, distinct, typo-tolerance,
|
1942
|
+
word proximity, geo distance and number of matched words are disabled. Results
|
1943
|
+
are still returned ranked by attributes and custom ranking.
|
1944
|
+
|
1945
|
+
|
1946
|
+
Example:
|
1947
|
+
|
1948
|
+
```ruby
|
1949
|
+
# Iterate with a filter over the index
|
1950
|
+
index.browse({:query => "test", :numericFilters => 'i=42'}) do
|
1951
|
+
# Do something
|
1952
|
+
end
|
1953
|
+
```
|
1954
|
+
|
1955
|
+
|
1956
|
+
|
1957
|
+
|
1958
|
+
API Keys
|
1911
1959
|
==================
|
1912
1960
|
|
1913
1961
|
The ADMIN API key provides full control of all your indices.
|
1914
1962
|
You can also generate user API keys to control security.
|
1915
1963
|
These API keys can be restricted to a set of operations or/and restricted to a given index.
|
1916
1964
|
|
1917
|
-
|
1965
|
+
## List API keys
|
1966
|
+
|
1967
|
+
To list existing keys, you can use:
|
1968
|
+
|
1918
1969
|
```ruby
|
1919
1970
|
# Lists global API Keys
|
1920
1971
|
Algolia.list_user_keys
|
@@ -1933,7 +1984,10 @@ Each key is defined by a set of permissions that specify the authorized actions.
|
|
1933
1984
|
* **analytics**: Allowed to retrieve analytics through the analytics API.
|
1934
1985
|
* **listIndexes**: Allowed to list all accessible indexes.
|
1935
1986
|
|
1936
|
-
|
1987
|
+
## Create API keys
|
1988
|
+
|
1989
|
+
To create API keys:
|
1990
|
+
|
1937
1991
|
```ruby
|
1938
1992
|
# Creates a new global API key that can only perform search actions
|
1939
1993
|
res = Algolia.add_user_key(["search"])
|
@@ -2087,7 +2141,9 @@ res = Algolia.add_user_key(params)
|
|
2087
2141
|
puts res['key']
|
2088
2142
|
```
|
2089
2143
|
|
2090
|
-
Update
|
2144
|
+
## Update API keys
|
2145
|
+
|
2146
|
+
To update the permissions of an existing key:
|
2091
2147
|
```ruby
|
2092
2148
|
# Update an existing global API key that is valid for 300 seconds
|
2093
2149
|
res = Algolia.update_user_key("myAPIKey", ["search"], 300)
|
@@ -2100,7 +2156,7 @@ puts res['key']
|
|
2100
2156
|
res = index.update_user_key("myAPIKey", ["search"], 300, 100, 20, ['my_index1', 'my_index2'])
|
2101
2157
|
puts res['key']
|
2102
2158
|
```
|
2103
|
-
|
2159
|
+
To get the permissions of a given key:
|
2104
2160
|
```ruby
|
2105
2161
|
# Gets the rights of a global key
|
2106
2162
|
Algolia.get_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
@@ -2108,7 +2164,9 @@ Algolia.get_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
|
2108
2164
|
index.get_user_key("71671c38001bf3ac857bc82052485107")
|
2109
2165
|
```
|
2110
2166
|
|
2111
|
-
Delete
|
2167
|
+
## Delete API keys
|
2168
|
+
|
2169
|
+
To delete an existing key:
|
2112
2170
|
```ruby
|
2113
2171
|
# Deletes a global key
|
2114
2172
|
Algolia.delete_user_key("f420238212c54dcfad07ea0aa6d5c45f")
|
@@ -2118,7 +2176,9 @@ index.delete_user_key("71671c38001bf3ac857bc82052485107")
|
|
2118
2176
|
|
2119
2177
|
|
2120
2178
|
|
2121
|
-
|
2179
|
+
## Secured API keys (frontend)
|
2180
|
+
|
2181
|
+
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:
|
2122
2182
|
|
2123
2183
|
```ruby
|
2124
2184
|
# generate a public API key for user 42. Here, records are tagged with:
|
@@ -2148,7 +2208,7 @@ You can mix rate limits and secured API keys by setting a `userToken` query para
|
|
2148
2208
|
```ruby
|
2149
2209
|
# generate a public API key for user 42. Here, records are tagged with:
|
2150
2210
|
# - 'user_XXXX' if they are visible by user XXXX
|
2151
|
-
public_key = Algolia.generate_secured_api_key '
|
2211
|
+
public_key = Algolia.generate_secured_api_key 'YourSearchOnlyApiKey', {'tagFilters'=> 'user_42', 'userToken'=> 'user_42'}
|
2152
2212
|
```
|
2153
2213
|
|
2154
2214
|
This public API key can then be used in your JavaScript code as follow:
|
@@ -2169,54 +2229,6 @@ index.search('another query', function(err, content) {
|
|
2169
2229
|
```
|
2170
2230
|
|
2171
2231
|
|
2172
|
-
Copy or rename an index
|
2173
|
-
==================
|
2174
|
-
|
2175
|
-
You can easily copy or rename an existing index using the `copy` and `move` commands.
|
2176
|
-
**Note**: Move and copy commands overwrite the destination index.
|
2177
|
-
|
2178
|
-
```ruby
|
2179
|
-
# Rename MyIndex in MyIndexNewName
|
2180
|
-
puts Algolia.move_index("MyIndex", "MyIndexNewName")
|
2181
|
-
# Copy MyIndex in MyIndexCopy
|
2182
|
-
puts Algolia.copy_index("MyIndex", "MyIndexCopy")
|
2183
|
-
```
|
2184
|
-
|
2185
|
-
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:
|
2186
|
-
1. Import your database into a new index using [batches](#batch-writes). Let's call this new index `MyNewIndex`.
|
2187
|
-
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.
|
2188
|
-
|
2189
|
-
```ruby
|
2190
|
-
# Rename MyNewIndex in MyIndex (and overwrite it)
|
2191
|
-
puts Algolia.move_index("MyNewIndex", "MyIndex")
|
2192
|
-
```
|
2193
|
-
|
2194
|
-
|
2195
|
-
Backup / Retrieve of all index content
|
2196
|
-
==================
|
2197
|
-
|
2198
|
-
The `search` method cannot return more than 1,000 results. If you need to
|
2199
|
-
retrieve all the content of your index (for backup, SEO purposes or for running
|
2200
|
-
a script on it), you should use the `browse` method instead. This method lets
|
2201
|
-
you retrieve objects beyond the 1,000 limit.
|
2202
|
-
|
2203
|
-
This method is optimized for speed. To make it fast, distinct, typo-tolerance,
|
2204
|
-
word proximity, geo distance and number of matched words are disabled. Results
|
2205
|
-
are still returned ranked by attributes and custom ranking.
|
2206
|
-
|
2207
|
-
|
2208
|
-
Example:
|
2209
|
-
|
2210
|
-
```ruby
|
2211
|
-
# Iterate with a filter over the index
|
2212
|
-
index.browse({:query => "test", :numericFilters => 'i=42'}) do
|
2213
|
-
# Do something
|
2214
|
-
end
|
2215
|
-
```
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
2232
|
Logs
|
2221
2233
|
==================
|
2222
2234
|
|
data/lib/algolia/client.rb
CHANGED
@@ -389,7 +389,7 @@ module Algolia
|
|
389
389
|
hinfo[:session].connect_timeout = connect_timeout
|
390
390
|
hinfo[:session].send_timeout = send_timeout
|
391
391
|
hinfo[:session].receive_timeout = receive_timeout
|
392
|
-
hinfo[:session].ssl_config.add_trust_ca File.join(File.dirname(__FILE__), '..', '..', 'resources', 'ca-bundle.crt')
|
392
|
+
hinfo[:session].ssl_config.add_trust_ca File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'resources', 'ca-bundle.crt'))
|
393
393
|
hinfo
|
394
394
|
end
|
395
395
|
end
|
data/lib/algolia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.4.8
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A simple Ruby client for the algolia.com REST API
|