searchkick 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9afc0023095cdc587ed6df4faedb9c6ba0927b61
4
- data.tar.gz: ff38cab705eb7d2692e81510ff237707820f1bda
3
+ metadata.gz: 2b15fd3f6aa1493ee75fee109a3420fb8e79bed7
4
+ data.tar.gz: c8cf011a7e5fb72bb25fe131eaa655be2713def7
5
5
  SHA512:
6
- metadata.gz: af68e2a80fc2f8cead9075b8e2e2928ab81dcf98952949f2901d24f151de235b5e648316dce80c84b9197d6b549efc43fb9ed1f04e8f79a8a834e671e68171aa
7
- data.tar.gz: b0a23d33695f2b82d84eb2152b07ca43d610ff1ba2200b917baaba61c3a7e8e7292161108270800afba3673484fefc8f19a7757ff2cbac0d131e7c36cccd3a5c
6
+ metadata.gz: b7c45c3c3627c02a45c7cc4380d59404d334fb2a0e1e4a327b472cb14dcac12df59843f5bf146185c76998409fcadb850393b0c92e89e0f6a20972445fbe1735
7
+ data.tar.gz: 616ca8f2a7776ca7f830cb2679bdbd7769460061107ed833f607896cfa2d637927011a40c958e026f0717de9471dd64f2bad157fbb55b79d93019132a7f8a605
data/README.md CHANGED
@@ -287,6 +287,8 @@ Product.search "2% Milk", facets: {store_id: {where: {in_stock: true}}}
287
287
 
288
288
  ## Deployment
289
289
 
290
+ Searchkick uses `ENV["ELASTICSEARCH_URL"]` for the Elasticsearch server. This defaults to `http://localhost:9200`.
291
+
290
292
  ### Heroku
291
293
 
292
294
  Choose an add-on: [SearchBox](https://addons.heroku.com/searchbox), [Bonsai](https://addons.heroku.com/bonsai), or [Found](https://addons.heroku.com/foundelasticsearch).
@@ -294,25 +296,29 @@ Choose an add-on: [SearchBox](https://addons.heroku.com/searchbox), [Bonsai](htt
294
296
  ```sh
295
297
  # SearchBox
296
298
  heroku addons:add searchbox:starter
299
+ heroku config:add ELASTICSEARCH_URL=`heroku config:get SEARCHBOX_URL`
297
300
 
298
301
  # Bonsai
299
302
  heroku addons:add bonsai
303
+ heroku config:add ELASTICSEARCH_URL=`heroku config:get BONSAI_URL`
300
304
 
301
305
  # Found
302
306
  heroku addons:add foundelasticsearch
307
+ heroku config:add ELASTICSEARCH_URL=`heroku config:get FOUNDELASTICSEARCH_URL`
303
308
  ```
304
309
 
305
- And create an initializer `config/initializers/elasticsearch.rb` with:
310
+ Then deploy and reindex:
306
311
 
307
- ```ruby
308
- # SearchBox
309
- ENV["ELASTICSEARCH_URL"] = ENV["SEARCHBOX_URL"]
312
+ ```sh
313
+ heroku run rake searchkick:reindex CLASS=Product
314
+ ```
310
315
 
311
- # Bonsai
312
- ENV["ELASTICSEARCH_URL"] = ENV["BONSAI_URL"]
316
+ ### Other
313
317
 
314
- # Found
315
- ENV["ELASTICSEARCH_URL"] = ENV["FOUNDELASTICSEARCH_URL"]
318
+ Create an initializer `config/initializers/elasticsearch.rb` with:
319
+
320
+ ```ruby
321
+ ENV["ELASTICSEARCH_URL"] = "http://username:password@api.searchbox.io"
316
322
  ```
317
323
 
318
324
  Then deploy and reindex:
@@ -5,6 +5,7 @@ require "searchkick/results"
5
5
  require "searchkick/search"
6
6
  require "searchkick/model"
7
7
  require "searchkick/tasks"
8
+ require "searchkick/logger" if defined?(Rails)
8
9
 
9
10
  # TODO find better ActiveModel hook
10
11
  ActiveModel::AttributeMethods::ClassMethods.send(:include, Searchkick::Model)
@@ -0,0 +1,19 @@
1
+ require "tire/rails/logger"
2
+ require "tire/rails/logger/log_subscriber"
3
+
4
+ class Tire::Rails::LogSubscriber
5
+
6
+ # better output format
7
+ def search(event)
8
+ self.class.runtime += event.duration
9
+ return unless logger.debug?
10
+
11
+ payload = event.payload
12
+
13
+ name = "%s (%.1fms)" % [payload[:name], event.duration]
14
+ query = payload[:search].to_s
15
+
16
+ debug " #{color(name, YELLOW, true)} #{query}"
17
+ end
18
+
19
+ end
@@ -57,12 +57,12 @@ module Searchkick
57
57
  tokenizer: "standard",
58
58
  # synonym should come last, after stemming and shingle
59
59
  # shingle must come before snowball
60
- filter: ["standard", "lowercase", "asciifolding", "stop", "snowball", "searchkick_index_shingle", "snowball"]
60
+ filter: ["standard", "lowercase", "asciifolding", "stop", "searchkick_index_shingle", "snowball"]
61
61
  },
62
62
  searchkick_search: {
63
63
  type: "custom",
64
64
  tokenizer: "standard",
65
- filter: ["standard", "lowercase", "asciifolding", "stop", "snowball", "searchkick_search_shingle", "snowball"]
65
+ filter: ["standard", "lowercase", "asciifolding", "stop", "searchkick_search_shingle", "snowball"]
66
66
  },
67
67
  searchkick_search2: {
68
68
  type: "custom",
@@ -182,6 +182,10 @@ module Searchkick
182
182
 
183
183
  payload = s.to_hash
184
184
 
185
+ # An empty array will cause only the _id and _type for each hit to be returned
186
+ # http://www.elasticsearch.org/guide/reference/api/search/fields/
187
+ payload[:fields] = [] if load
188
+
185
189
  # suggestions
186
190
  if options[:suggest]
187
191
  suggest_fields = (@searchkick_options[:suggest] || []).map(&:to_s)
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "tire"
22
+ spec.add_dependency "tire-contrib"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.3"
24
25
  spec.add_development_dependency "rake"
@@ -29,6 +29,11 @@ class TestMatch < Minitest::Unit::TestCase
29
29
  assert_search "dish soap", ["Dish Washer Amazing Organic Soap"]
30
30
  end
31
31
 
32
+ def test_middle_token_wine
33
+ store_names ["Beringer Wine Founders Estate Chardonnay"]
34
+ assert_search "beringer chardonnay", ["Beringer Wine Founders Estate Chardonnay"]
35
+ end
36
+
32
37
  def test_percent
33
38
  store_names ["1% Milk", "2% Milk", "Whole Milk"]
34
39
  assert_search "1%", ["1% Milk"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tire-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +121,7 @@ files:
107
121
  - README.md
108
122
  - Rakefile
109
123
  - lib/searchkick.rb
124
+ - lib/searchkick/logger.rb
110
125
  - lib/searchkick/model.rb
111
126
  - lib/searchkick/reindex.rb
112
127
  - lib/searchkick/results.rb