redis-search 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +13 -9
- data/lib/redis/search/base.rb +8 -3
- data/lib/redis/search/finder.rb +2 -2
- data/lib/redis/search/railtie.rb +2 -2
- metadata +27 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fd041bc3357ace32de60abc0360f57e8b547a766
|
4
|
+
data.tar.gz: 2669938cf7809390388715b536d91b7c80492072
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8c77602acef1e986a35497c320f563a880d38034dd521c5b02d39d120451776d685ada73066968e0ec09da8cb527398416e33669459f2726e11b84d772de1e6
|
7
|
+
data.tar.gz: 6a8e6bfdce8b72afd45f58afa24652ae16f3c88d1921c1fea5f4cbad03fc58748a3d90e2fc4993a13c06252be27626f87f1e8114fdd15224fbb3867960b6baf5
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Jason Lee
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -10,6 +10,8 @@ High performance real-time search (Support Chinese), index in Redis for Rails ap
|
|
10
10
|
|
11
11
|
You can try the search feature in [`720p.so`](http://720p.so) | [`shu.im`](http://shu.im)
|
12
12
|
|
13
|
+
And there is an [Example App](https://github.com/huacnlee/redis-search-example) to show you how to use redis-search.
|
14
|
+
|
13
15
|
## Master Status
|
14
16
|
|
15
17
|
[![CI Status](https://secure.travis-ci.org/huacnlee/redis-search.png)](http://travis-ci.org/huacnlee/redis-search)
|
@@ -35,12 +37,8 @@ You can try the search feature in [`720p.so`](http://720p.so) | [`shu.im`](http:
|
|
35
37
|
1. In Rails application Gemfile
|
36
38
|
|
37
39
|
```ruby
|
38
|
-
gem '
|
39
|
-
gem '
|
40
|
-
# add rmmseg if you need search by segment words
|
41
|
-
gem 'rmmseg-cpp-huacnlee', '0.2.9'
|
42
|
-
gem 'redis-namespace','~> 1.1.0'
|
43
|
-
gem 'redis-search', '0.8.0'
|
40
|
+
gem 'ruby-pinyin', '0.3.0'
|
41
|
+
gem 'redis-search', '0.9.0'
|
44
42
|
```
|
45
43
|
|
46
44
|
```bash
|
@@ -103,13 +101,13 @@ You can try the search feature in [`720p.so`](http://720p.so) | [`shu.im`](http:
|
|
103
101
|
include Redis::Search
|
104
102
|
|
105
103
|
field :name
|
106
|
-
|
104
|
+
field :alias_names, :type => Array
|
107
105
|
field :tagline
|
108
106
|
field :email
|
109
107
|
field :followers_count
|
110
108
|
|
111
109
|
redis_search_index(:title_field => :name,
|
112
|
-
|
110
|
+
:alias_field => :alias_names,
|
113
111
|
:prefix_index_enable => true,
|
114
112
|
:score_field => :followers_count,
|
115
113
|
:ext_fields => [:email,:tagline])
|
@@ -140,7 +138,8 @@ $ rake redis_search:index
|
|
140
138
|
|
141
139
|
## Documentation
|
142
140
|
|
143
|
-
See [Rdoc.info redis-search](http://rubydoc.info/gems/redis-search)
|
141
|
+
* See [Rdoc.info redis-search](http://rubydoc.info/gems/redis-search)
|
142
|
+
* [Example App](https://github.com/huacnlee/redis-search-example)
|
144
143
|
|
145
144
|
## Benchmark test
|
146
145
|
|
@@ -148,3 +147,8 @@ You can run the rake command (see Rakefile) to make test.
|
|
148
147
|
There is my performance test result.
|
149
148
|
|
150
149
|
* [https://gist.github.com/1150933](https://gist.github.com/1150933)
|
150
|
+
|
151
|
+
|
152
|
+
## License
|
153
|
+
|
154
|
+
* [Apache V2](http://choosealicense.com/licenses/nses/apache)
|
data/lib/redis/search/base.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
class Redis
|
3
4
|
module Search
|
4
|
-
extend ActiveSupport::Concern
|
5
|
+
extend ::ActiveSupport::Concern
|
5
6
|
|
6
7
|
module ClassMethods
|
7
8
|
# Config redis-search index for Model
|
@@ -17,12 +18,16 @@ class Redis
|
|
17
18
|
prefix_index_enable = options[:prefix_index_enable] || false
|
18
19
|
ext_fields = options[:ext_fields] || []
|
19
20
|
score_field = options[:score_field] || :created_at
|
20
|
-
condition_fields = options[:condition_fields] || []
|
21
|
+
condition_fields = options[:condition_fields] || []
|
21
22
|
# Add score field to ext_fields
|
22
23
|
ext_fields |= [score_field]
|
23
24
|
# Add condition fields to ext_fields
|
24
25
|
ext_fields |= condition_fields
|
25
26
|
|
27
|
+
if RUBY_VERSION.start_with?('1.8')
|
28
|
+
condition_fields = "[#{condition_fields.collect { |c| "'#{c}'" }.join(',')}]"
|
29
|
+
end
|
30
|
+
|
26
31
|
# store Model name to indexed_models for Rake tasks
|
27
32
|
Search.indexed_models = [] if Search.indexed_models == nil
|
28
33
|
Search.indexed_models << self
|
@@ -125,4 +130,4 @@ class Redis
|
|
125
130
|
end
|
126
131
|
end
|
127
132
|
end
|
128
|
-
end
|
133
|
+
end
|
data/lib/redis/search/finder.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
require '
|
2
|
+
require 'ruby-pinyin'
|
3
3
|
class Redis
|
4
4
|
module Search
|
5
5
|
# use rmmseg to split words
|
@@ -176,7 +176,7 @@ class Redis
|
|
176
176
|
protected
|
177
177
|
def self.split_pinyin(text)
|
178
178
|
# Pinyin search split as pinyin again
|
179
|
-
_split(
|
179
|
+
_split(PinYin.sentence(text))
|
180
180
|
end
|
181
181
|
|
182
182
|
private
|
data/lib/redis/search/railtie.rb
CHANGED
metadata
CHANGED
@@ -1,103 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jason Lee
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: ruby-pinyin
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
- - ">="
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 0.3.0
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.3'
|
30
|
+
- - ">="
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: 0.3.0
|
30
33
|
- !ruby/object:Gem::Dependency
|
31
34
|
name: redis-namespace
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
36
|
requirements:
|
35
|
-
- -
|
37
|
+
- - ">="
|
36
38
|
- !ruby/object:Gem::Version
|
37
39
|
version: 1.0.2
|
38
40
|
type: :runtime
|
39
41
|
prerelease: false
|
40
42
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
43
|
requirements:
|
43
|
-
- -
|
44
|
+
- - ">="
|
44
45
|
- !ruby/object:Gem::Version
|
45
46
|
version: 1.0.2
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
48
|
name: redis
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 2.1.1
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
57
|
requirements:
|
59
|
-
- -
|
58
|
+
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: 2.1.1
|
62
|
-
description: High performance real-time search (Support Chinese), index in Redis
|
63
|
-
Rails application.
|
61
|
+
description: 'High performance real-time search (Support Chinese), index in Redis
|
62
|
+
for Rails application. '
|
64
63
|
email:
|
65
64
|
- huacnlee@gmail.com
|
66
65
|
executables: []
|
67
66
|
extensions: []
|
68
67
|
extra_rdoc_files: []
|
69
68
|
files:
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- lib/redis-search.rb
|
70
72
|
- lib/redis/search/base.rb
|
71
73
|
- lib/redis/search/config.rb
|
72
74
|
- lib/redis/search/finder.rb
|
73
75
|
- lib/redis/search/index.rb
|
74
76
|
- lib/redis/search/railtie.rb
|
75
77
|
- lib/redis/search/tasks.rb
|
76
|
-
- lib/redis-search.rb
|
77
|
-
- README.md
|
78
78
|
homepage: http://github.com/huacnlee/redis-search
|
79
|
-
licenses:
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
80
82
|
post_install_message:
|
81
83
|
rdoc_options: []
|
82
84
|
require_paths:
|
83
85
|
- lib
|
84
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
87
|
requirements:
|
87
|
-
- -
|
88
|
+
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: 1.3.6
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version:
|
98
|
+
rubygems_version: 2.2.0.rc.1
|
99
99
|
signing_key:
|
100
|
-
specification_version:
|
100
|
+
specification_version: 4
|
101
101
|
summary: High performance real-time search (Support Chinese), index in Redis for Rails
|
102
102
|
application.
|
103
103
|
test_files: []
|