redis-search 1.0.0.beta2 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f2a414c25a8c0f48c9cc236fdb4c905da7bd5e4
4
- data.tar.gz: 3b9074ed892c0711245c342fcd1c381140ea17d8
3
+ metadata.gz: 12ec25b07a9d7ffd659fbce03abddb49d0822667
4
+ data.tar.gz: 301390053cba3ac658d84e5c00e69c98467e17c5
5
5
  SHA512:
6
- metadata.gz: 765e256b56b74776f33275ddfe8dfb8aac31ccfd283398d27e29057eb94e2db3808f1dd3ac2025a7dbe34ac10b0e9a23d5a31bbc2fd5e061e591be6af4662433
7
- data.tar.gz: b1b642a1701492a20b2b5db3856e03ac787f28e6a1e0aa57791445f5cffd27248c6a4d7a77c0e4dd47ef9f4ae67d18d391f06f5f538ebb290f0deb7260552ae6
6
+ metadata.gz: 9b2622a8e197aeb48566b9ef138b4fd83dd3cec4d91047ee8782516e039f6ddbf032c7d05d03c1a45c4d8642484905d955e88fe0722f5f2832cd6b43407720c0
7
+ data.tar.gz: 4e3c850559c3e9c5c7ec962c057a2d03e72184394f12a0976522669ecdbbda5b76cf6306bcd421326bd355ad6bf6d033a011bcdac07564c3d5add43256c64b94
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Redis-Search
2
2
 
3
- High performance real-time search (Support Chinese), index in Redis for Rails application
3
+ High performance real-time prefix search, indexes store in Redis for Rails application.
4
4
 
5
5
  [中文介绍和使用说明](https://github.com/huacnlee/redis-search/wiki/Usage-in-Chinese)
6
6
 
@@ -151,6 +151,7 @@ Projects used redis-search:
151
151
 
152
152
  - [redis-search-example](https://github.com/huacnlee/redis-search-example) - An example for show you how to use redis-search.
153
153
  - [IMAX.im](https://github.com/huacnlee/imax.im)
154
+ - [Ruby China](https://ruby-china.org) - Use for mention autocomplete.
154
155
 
155
156
  ## License
156
157
 
@@ -3,6 +3,8 @@ class Redis
3
3
  module Search
4
4
  autoload :PinYin, 'ruby-pinyin'
5
5
 
6
+ DOT = '.'.freeze
7
+
6
8
  extend ActiveSupport::Concern
7
9
 
8
10
  included do
@@ -149,19 +151,11 @@ class Redis
149
151
  count = 0
150
152
  if ancestors.collect(&:to_s).include?('ActiveRecord::Base'.freeze)
151
153
  find_in_batches(batch_size: batch_size) do |items|
152
- items.each do |item|
153
- item.redis_search_index_create
154
- count += 1
155
- print '.' if progressbar
156
- end
154
+ _redis_search_reindex_items(items)
157
155
  end
158
156
  elsif included_modules.collect(&:to_s).include?('Mongoid::Document'.freeze)
159
157
  all.each_slice(batch_size) do |items|
160
- items.each do |item|
161
- item.redis_search_index_create
162
- count += 1
163
- print '.' if progressbar
164
- end
158
+ _redis_search_reindex_items(items)
165
159
  end
166
160
  else
167
161
  puts 'skiped, not support this ORM in current.'
@@ -169,6 +163,18 @@ class Redis
169
163
 
170
164
  count
171
165
  end
166
+
167
+ private
168
+
169
+ def _redis_search_reindex_items(items)
170
+ items.each do |item|
171
+ item.redis_search_index_create
172
+ count += 1
173
+ print DOT if progressbar
174
+ item = nil
175
+ end
176
+ items = nil
177
+ end
172
178
  end
173
179
  end
174
180
  end
@@ -8,6 +8,7 @@ class Redis
8
8
  # type model name
9
9
  # w search char
10
10
  # :limit result limit
11
+ # :order result order
11
12
  #
12
13
  # h3. usage:
13
14
  #
@@ -18,6 +19,7 @@ class Redis
18
19
  def complete(type, w, options = {})
19
20
  limit = options[:limit] || 10
20
21
  conditions = options[:conditions] || []
22
+ order = options[:order] || 'desc'
21
23
  return [] if (w.blank? && conditions.blank?) || type.blank?
22
24
 
23
25
  prefix_matchs = []
@@ -88,7 +90,7 @@ class Redis
88
90
  ids = config.redis.sort(temp_store_key,
89
91
  limit: [0, limit],
90
92
  by: mk_score_key(type, '*'),
91
- order: 'desc')
93
+ order: order)
92
94
  return [] if ids.blank?
93
95
  hmget(type, ids)
94
96
  end
@@ -31,13 +31,13 @@ namespace :redis_search do
31
31
  exit(1)
32
32
  end
33
33
 
34
- klass = eval(ENV['CLASS'].to_s)
35
- batch = ENV['BATCH'].to_i > 0 ? ENV['BATCH'].to_i : 1000
36
- tm = Time.now
34
+ klass = Object.const_get((ENV['CLASS'].to_s)
35
+ batch = ENV['BATCH'].to_i || 1000
36
+ start = Time.now
37
37
  puts "Redis-Search index data to Redis from [#{klass}]"
38
38
  count = klass.redis_search_index_batch_create(batch, true)
39
39
  puts ''
40
- puts "Indexed #{count} rows | Time spend: #{(Time.now - tm)}s"
40
+ puts "Indexed #{count} rows | Time spend: #{(Time.now - start)}s"
41
41
  puts 'Rebuild Index done.'
42
42
  end
43
43
 
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  module Search
3
- VERSION = '1.0.0.beta2'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-pinyin
@@ -58,8 +58,8 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 3.0.0
61
- description: 'High performance real-time search (Support Chinese), indexes store in
62
- Redis for Rails applications. '
61
+ description: High performance real-time prefix search, indexes store in Redis for
62
+ Rails application.
63
63
  email:
64
64
  - huacnlee@gmail.com
65
65
  executables: []
@@ -93,12 +93,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.3.6
96
+ version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
99
  rubygems_version: 2.5.1
100
100
  signing_key:
101
101
  specification_version: 4
102
- summary: High performance real-time search (Support Chinese), indexes store in Redis
103
- for Rails applications.
102
+ summary: High performance real-time prefix search.
104
103
  test_files: []