searchkick 0.1.0 → 0.1.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: edbfa8b338d8ddc3b4bcef4755151c98c7afeb30
4
- data.tar.gz: aa1e1fbda8e995dfeb22cb005b5fc755020980bf
3
+ metadata.gz: 8b5ae6918d441a036655f1e686a97994c27cd3d0
4
+ data.tar.gz: 8bfc3d79c77b03afefb8791c0663bb26cd6e6bda
5
5
  SHA512:
6
- metadata.gz: 531313b35dae913d8d999fe3283c2a2535ada666c58c567cc385ac6574dbec0015bf65f2dbacdc1ac07b18eaca31d40aa776d968d1cb36db16f06dc34de633af
7
- data.tar.gz: c3bd0aaee05a28b95d2884104144bc7058f26bd3b2c5eba75c68b02022c203bd3326fdfe99702139d264d386f92879467afb69f783a354662f188ead85788086
6
+ metadata.gz: b3883c5f4da5b1012e41350f3cc5356c9570d3482d8b9e7fe2bfd660de54b4028cee9841259c23e2f9eace042eb7c0d523ef43afd27c118dce156990980b49ea
7
+ data.tar.gz: dd6cb042bd1de8627abe1f3aa61150684cf8f6d9235943b1b5f149d612fa26bface7b71ff019497ed76b0577019510bc6ff22ff152f78fde7de9443b81bb08ee
data/README.md CHANGED
@@ -16,8 +16,6 @@ Plus:
16
16
  - reindex without downtime
17
17
  - continually improve results from conversions - **pretty awesome**
18
18
 
19
- Powered by Elasticsearch
20
-
21
19
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com)
22
20
 
23
21
  ## Get Started
@@ -54,7 +52,6 @@ And to query, use:
54
52
  products = Product.search "2% Milk"
55
53
  products.each do |product|
56
54
  puts product.name
57
- puts product._score # added by searchkick - between 0 and 1
58
55
  end
59
56
  ```
60
57
 
@@ -147,7 +144,7 @@ Choose what data is indexed.
147
144
 
148
145
  ```ruby
149
146
  class Product < ActiveRecord::Base
150
- def _source
147
+ def search_data
151
148
  as_json only: [:name, :active], include: {brand: {only: [:city]}}
152
149
  # or equivalently
153
150
  {
@@ -161,11 +158,11 @@ class Product < ActiveRecord::Base
161
158
  end
162
159
  ```
163
160
 
164
- Searchkick uses `find_in_batches` to import documents. To eager load associations, use the `searchkick_import` scope.
161
+ Searchkick uses `find_in_batches` to import documents. To eager load associations, use the `search_import` scope.
165
162
 
166
163
  ```ruby
167
164
  class Product < ActiveRecord::Base
168
- scope :searchkick_import, includes(:searches)
165
+ scope :search_import, includes(:searches)
169
166
  end
170
167
  ```
171
168
 
@@ -188,7 +185,7 @@ Add conversions to the index.
188
185
  class Product < ActiveRecord::Base
189
186
  has_many :searches
190
187
 
191
- def _source
188
+ def search_data
192
189
  {
193
190
  name: name,
194
191
  conversions: searches.group("query").count
@@ -218,18 +215,32 @@ Product.search "2% Milk", facets: {store_id: {where: {in_stock: true}}}
218
215
 
219
216
  ## Deployment
220
217
 
221
- ### Bonsai on Heroku
218
+ ### Heroku
222
219
 
223
- Install the add-on:
220
+ Choose an add-on: [SearchBox](https://addons.heroku.com/searchbox), [Bonsai](https://addons.heroku.com/bonsai), or [Found](https://addons.heroku.com/foundelasticsearch).
224
221
 
225
222
  ```sh
223
+ # SearchBox
224
+ heroku addons:add searchbox:starter
225
+
226
+ # Bonsai
226
227
  heroku addons:add bonsai
228
+
229
+ # Found
230
+ heroku addons:add foundelasticsearch
227
231
  ```
228
232
 
229
- And create an initializer `config/initializers/bonsai.rb` with:
233
+ And create an initializer `config/initializers/elasticsearch.rb` with:
230
234
 
231
235
  ```ruby
236
+ # SearchBox
237
+ ENV["ELASTICSEARCH_URL"] = ENV["SEARCHBOX_URL"]
238
+
239
+ # Bonsai
232
240
  ENV["ELASTICSEARCH_URL"] = ENV["BONSAI_URL"]
241
+
242
+ # Found
243
+ ENV["ELASTICSEARCH_URL"] = ENV["FOUNDELASTICSEARCH_URL"]
233
244
  ```
234
245
 
235
246
  Then deploy and reindex:
@@ -13,18 +13,17 @@ module Searchkick
13
13
  tire do
14
14
  index_name options[:index_name] || [klass.model_name.plural, ENV["RACK_ENV"] || "development"].join("_")
15
15
  end
16
- attr_accessor :_score
17
16
 
18
17
  def reindex
19
18
  update_index
20
19
  end
21
20
 
22
- def _source
21
+ def search_data
23
22
  as_json
24
23
  end
25
24
 
26
25
  def to_indexed_json
27
- source = _source
26
+ source = search_data
28
27
  if self.class.instance_variable_get("@searchkick_options")[:conversions] and source[:conversions]
29
28
  source[:conversions] = source[:conversions].map{|k, v| {query: k, count: v} }
30
29
  end
@@ -10,7 +10,7 @@ module Searchkick
10
10
  index.create searchkick_index_options
11
11
 
12
12
  # use scope for import
13
- scope = respond_to?(:searchkick_import) ? searchkick_import : self
13
+ scope = respond_to?(:search_import) ? search_import : self
14
14
  scope.find_in_batches do |batch|
15
15
  index.import batch
16
16
  end
@@ -137,9 +137,6 @@ module Searchkick
137
137
  end
138
138
  end
139
139
 
140
- collection.each_with_hit do |model, hit|
141
- model._score = hit["_score"].to_f / collection.max_score
142
- end
143
140
  collection
144
141
  end
145
142
 
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -14,10 +14,9 @@ class Product < ActiveRecord::Base
14
14
  ],
15
15
  settings: {
16
16
  number_of_shards: 1
17
- },
18
- conversions: true
17
+ }
19
18
 
20
- def _source
19
+ def search_data
21
20
  as_json.merge conversions: searches.group("query").count
22
21
  end
23
22
  end
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane