smart_search 0.0.68 → 0.0.72

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smart_search.rb +20 -14
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f60a9bffb75ceceade932e2331a8f14f1ff1b6ae
4
- data.tar.gz: 6f24ec4a0817fd3a165a85d8f5fc37020cdd9c8d
3
+ metadata.gz: dfd2dd9fd04bc74f2c8697af8b3ee58145f9f64a
4
+ data.tar.gz: 8021f287ed9b035434f002837ec3a9eef612253d
5
5
  SHA512:
6
- metadata.gz: 0d9560a45cd4924650aad7b77b5c8d368b4f4bec1aac7d343ce4fdab8f9753ca216b1174858273a175911f81347235e18341771ca50e79748c5d2c40e70bc8ea
7
- data.tar.gz: ab00b0d1a76232e7e755610ca4010b9bfa93d60aa568149a9302c623d19cc68b2b97818d58d6072827d64f7bbff3ec5143a335b3e44559fad4a982b2eecc6d9d
6
+ metadata.gz: b1ec9e9a8c55ce8cda457288a7dc1dff33adfd5f847fd13d33f90601410759313f23b1352ef4efd7cbaf0f49c5d2f86919ecdd4c5c05402364bd4e5575eb99d3
7
+ data.tar.gz: ca66520132e062cd2cc711e5ffefc3f8f40ae04c524f8032fe07010d7b3064e396294912390a4c0d697b85c76533e580abab6170d35f4bdd0574f7ce46de951e
data/lib/smart_search.rb CHANGED
@@ -31,8 +31,8 @@ module SmartSearch
31
31
 
32
32
  cattr_accessor :condition_default, :group_default, :tags, :order_default, :enable_similarity, :default_template_path
33
33
  send :include, InstanceMethods
34
- self.send(:after_save, :create_search_tags)
35
- self.send(:before_destroy, :create_search_tags)
34
+ self.send(:after_save, :create_search_tags) unless options[:auto] == false
35
+ self.send(:before_destroy, :clear_search_tags)
36
36
  self.enable_similarity ||= true
37
37
 
38
38
  attr_accessor :query_score
@@ -143,7 +143,6 @@ module SmartSearch
143
143
  s = self.all.size.to_f
144
144
  self.all.each_with_index do |a, i|
145
145
  a.create_search_tags
146
- a.send(:update_without_callbacks)
147
146
  done = ((i+1).to_f/s)*100
148
147
  printf "Set search index for #{self.name}: #{done}%% \r"
149
148
  end
@@ -191,7 +190,7 @@ module SmartSearch
191
190
  tag[:search_tags] << tagx.to_s
192
191
  end
193
192
 
194
- tag[:search_tags] = tag[:search_tags].split(" ").uniq.join(" ").downcase
193
+ tag[:search_tags] = tag[:search_tags].split(" ").uniq.join(" ").downcase.clear_html
195
194
  tags << tag
196
195
  end
197
196
 
@@ -199,18 +198,25 @@ module SmartSearch
199
198
  self.clear_search_tags
200
199
 
201
200
  # Merge search tags with same boost
202
- #merged_tags = {}
203
- #tags.each do |t|
204
- # if merged_tags[t[:boost]]
205
- # merged_tags[t[:boost]][:field_name] << ",#{t[:field_name].to_s}"
206
- # merged_tags[t[:boost]][:search_tags] << " #{t[:search_tags]}"
207
- # else
208
- # merged_tags[t[:boost]] = {:field_name => t[:field_name].to_s, :search_tags => t[:search_tags], :boost => t[:boost] }
209
- # end
210
- #end
201
+ @merged_tags = {}
211
202
 
212
203
  tags.each do |t|
213
- SmartSearchTag.create(t.merge!(:table_name => self.class.table_name, :entry_id => self.id))
204
+ boost = t[:boost]
205
+
206
+ if @merged_tags[boost]
207
+
208
+ @merged_tags[boost][:field_name] << ",#{t[:field_name]}"
209
+ @merged_tags[boost][:search_tags] << " #{t[:search_tags]}"
210
+ else
211
+ @merged_tags[boost] = {:field_name => "#{t[:field_name]}", :search_tags => t[:search_tags], :boost => boost }
212
+ end
213
+
214
+ end
215
+
216
+ @merged_tags.values.each do |t|
217
+ if !t[:search_tags].blank? && t[:search_tags].size > 1
218
+ SmartSearchTag.create(t.merge!(:table_name => self.class.table_name, :entry_id => self.id, :search_tags => t[:search_tags].strip.split(" ").uniq.join(" ")))
219
+ end
214
220
  end
215
221
 
216
222
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.68
4
+ version: 0.0.72
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Eck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-24 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.2.1
112
+ rubygems_version: 2.2.2
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Simple, easy to use search MySQL based search for ActiveRecord
@@ -120,4 +120,3 @@ test_files:
120
120
  - test/unit/01_smart_search_test.rb
121
121
  - test/unit/02_smart_search_similarity_test.rb
122
122
  - test/unit/03_smart_search_boost_test.rb
123
- has_rdoc: