redisearch-rb 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -16
- data/lib/redisearch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 989e86efdc440fc616ee1741256c81b829ca69b0
|
4
|
+
data.tar.gz: 2f2d59a65e355750b045f317dc7e6619d120bb0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b61fc7f81b2d86c33142c3c01a3b2b79647b5d40c0f5cfdca094ac9710104c439e153f8c8ab68a29503c97cbedc64a7f440824e02521051f7b0a304a59c25e4
|
7
|
+
data.tar.gz: 9208b2b791c07ce5a0dc7b700e9cefc99030a255444500a5bc99103a053b6af167baa17a14120cd7111c8b55a6804bb65ad81e393406a6e642a4a28a6f2f0253
|
data/README.md
CHANGED
@@ -10,8 +10,8 @@ http://redisearch.io/
|
|
10
10
|
|
11
11
|
First of all, you need to install RediSearch, if you haven't yet:
|
12
12
|
|
13
|
-
1. Install Redis 4.0.
|
14
|
-
2. Install RediSearch
|
13
|
+
1. Install Redis 4.0.1 https://github.com/antirez/redis/releases/tag/4.0.1
|
14
|
+
2. Install RediSearch http://redisearch.io/Quick_Start/
|
15
15
|
3. Edit your `redis.conf` file and add a `loadmodule` directive to load the RediSearch module built in the step 2.
|
16
16
|
|
17
17
|
To install this gem, add this line to your application's Gemfile:
|
@@ -33,16 +33,9 @@ In order to run the tests, it's necessary to set some env variables (see .env.ex
|
|
33
33
|
|
34
34
|
- `REDIS_SERVER_PATH`, the path to the `redis-server` executable
|
35
35
|
|
36
|
-
- `REDIS_MODULE_PATH`, the path to the
|
36
|
+
- `REDIS_MODULE_PATH`, the path to the `redisearch.so` module
|
37
37
|
|
38
|
-
- `
|
39
|
-
|
40
|
-
- `REDIS_TEST_URL` is the Redis url where the server will be available. The port has to match the port specified in
|
41
|
-
`REDIS_PORT` or in the redis config file
|
42
|
-
|
43
|
-
- `REDIS_CONF_PATH`, is the path to your redis conf file. You can configure the port and the path to RediSearch module in
|
44
|
-
a config file if you prefer. If the path to the config file is given, `REDIS_MODULE_PATH` and `REDIS_PORT` will be
|
45
|
-
ignored
|
38
|
+
- `REDIS_CONF_PATH`, the two previous parameters can be configured using a redis conf file. In case `REDIS_CONF_PATH` is given, the values of the env vars `REDIS_SERVER_PATH` and `REDIS_MODULE_PATH` are ignored.
|
46
39
|
|
47
40
|
|
48
41
|
## Usage
|
@@ -55,23 +48,27 @@ redisearch_client = RediSearch.new('test_idx', redis)
|
|
55
48
|
|
56
49
|
schema = ['title', 'TEXT', 'WEIGHT', '2.0',
|
57
50
|
'director', 'TEXT', 'WEIGHT', '1.0',
|
58
|
-
'year', 'NUMERIC']
|
51
|
+
'year', 'NUMERIC', 'SORTABLE']
|
59
52
|
|
60
|
-
redisearch_client.create_index(schema)
|
53
|
+
redisearch_client.create_index(schema, { nooffsets: true })
|
61
54
|
# => "OK"
|
62
55
|
|
63
56
|
docs = [['id_1', ['title', 'Lost in translation', 'director', 'Sofia Coppola', 'year', '2004']],
|
64
57
|
['id_2', ['title', 'Ex Machina', 'director', 'Alex Garland', 'year', '2014']]]
|
65
|
-
redisearch_client.add_docs(docs)
|
58
|
+
redisearch_client.add_docs(docs, { replace: true })
|
66
59
|
# => ["OK", "OK"]
|
67
60
|
|
68
61
|
# See query syntax here: http://redisearch.io/Query_Syntax/
|
69
|
-
redisearch_client.search('lost|machina', { withscores: true })
|
62
|
+
redisearch_client.search('lost|machina', { withscores: true, limit: ['0', '2'] })
|
70
63
|
# => [{"title"=>"Ex Machina", "director"=>"Alex Garland", "year"=>"2014", "score"=>"2", "id"=>"id_2"},
|
71
64
|
# {"title"=>"Lost in translation", "director"=>"Sofia Coppola", "year"=>"2004", "score"=>"1", "id"=>"id_1"}]
|
72
65
|
|
73
|
-
redisearch_client.search('@year:[2003
|
66
|
+
redisearch_client.search('@year:[2003 2017]', { sortby: ['year', 'asc'], limit: ['0', '1'] })
|
74
67
|
# => [{"title"=>"Lost in translation", "director"=>"Sofia Coppola", "year"=>"2004", "id"=>"id_1"}]
|
68
|
+
|
69
|
+
redisearch_client.search('@year:[2003 2017]', { sortby: ['year', 'asc'], limit: ['1', '1'] })
|
70
|
+
# => [{"title"=>"Ex Machina", "director"=>"Alex Garland", "year"=>"2014", "score"=>"2", "id"=>"id_2"}
|
71
|
+
|
75
72
|
```
|
76
73
|
|
77
74
|
## Contributing
|
data/lib/redisearch/version.rb
CHANGED