searchkick 1.3.5 → 1.3.6
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +15 -13
- data/lib/searchkick/version.rb +1 -1
- data/lib/searchkick.rb +9 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2665e44b0bd2b8e4bcceb5d9963acb49505914bb
|
4
|
+
data.tar.gz: f44ddcee8dd2b1ff0607aac73243a36a458179c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea59d44e55010236af8b16a1c3b1d7e7f160081f137cbdd44e298d291c6ae84a966be25a405f21f970885f07c73bf6e76c6e56edf29cba234c2ba308b6ba5241
|
7
|
+
data.tar.gz: 28c80bb3061751507605bebf0a4dacb541a4f8cfd6b98156c3cbfad2aa9de03c916aa12715bc47769a3a79b154d82f4c2bc901d34a7d314e57f2ac0d96fe5ee4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
:rocket: Intelligent search made easy
|
4
4
|
|
5
|
-
Searchkick learns what **your users** are looking for.
|
5
|
+
Searchkick learns what **your users** are looking for. As more people search, it gets smarter and the results get better. It’s friendly for developers - and magical for your users.
|
6
6
|
|
7
7
|
Searchkick handles:
|
8
8
|
|
@@ -265,7 +265,7 @@ User.search "fresh honey", match: :phrase
|
|
265
265
|
|
266
266
|
### Language
|
267
267
|
|
268
|
-
Searchkick defaults to English for stemming.
|
268
|
+
Searchkick defaults to English for stemming. To change this, use:
|
269
269
|
|
270
270
|
```ruby
|
271
271
|
class Product < ActiveRecord::Base
|
@@ -366,7 +366,7 @@ class Product < ActiveRecord::Base
|
|
366
366
|
end
|
367
367
|
```
|
368
368
|
|
369
|
-
Searchkick uses `find_in_batches` to import documents.
|
369
|
+
Searchkick uses `find_in_batches` to import documents. To eager load associations, use the `search_import` scope.
|
370
370
|
|
371
371
|
```ruby
|
372
372
|
class Product < ActiveRecord::Base
|
@@ -374,10 +374,12 @@ class Product < ActiveRecord::Base
|
|
374
374
|
end
|
375
375
|
```
|
376
376
|
|
377
|
-
By default, all records are indexed.
|
377
|
+
By default, all records are indexed. To control which records are indexed, use the `should_index?` method together with the `search_import` scope.
|
378
378
|
|
379
379
|
```ruby
|
380
380
|
class Product < ActiveRecord::Base
|
381
|
+
scope :search_import, -> { where(active: true) }
|
382
|
+
|
381
383
|
def should_index?
|
382
384
|
active # only index active records
|
383
385
|
end
|
@@ -450,7 +452,7 @@ end
|
|
450
452
|
|
451
453
|
#### Associations
|
452
454
|
|
453
|
-
Data is **not** automatically synced when an association is updated.
|
455
|
+
Data is **not** automatically synced when an association is updated. If this is desired, add a callback to reindex:
|
454
456
|
|
455
457
|
```ruby
|
456
458
|
class Image < ActiveRecord::Base
|
@@ -478,11 +480,11 @@ Product.search "apple", track: {user_id: current_user.id}
|
|
478
480
|
|
479
481
|
### Keep Getting Better
|
480
482
|
|
481
|
-
Searchkick can use conversion data to learn what users are looking for.
|
483
|
+
Searchkick can use conversion data to learn what users are looking for. If a user searches for “ice cream” and adds Ben & Jerry’s Chunky Monkey to the cart (our conversion metric at Instacart), that item gets a little more weight for similar searches.
|
482
484
|
|
483
|
-
The first step is to define your conversion metric and start tracking conversions.
|
485
|
+
The first step is to define your conversion metric and start tracking conversions. The database works well for low volume, but feel free to use Redis or another datastore.
|
484
486
|
|
485
|
-
You do **not** need to clean up the search queries.
|
487
|
+
You do **not** need to clean up the search queries. Searchkick automatically treats `apple` and `APPLES` the same.
|
486
488
|
|
487
489
|
Next, add conversions to the index.
|
488
490
|
|
@@ -510,7 +512,7 @@ rake searchkick:reindex CLASS=Product
|
|
510
512
|
|
511
513
|
### Personalized Results
|
512
514
|
|
513
|
-
Order results differently for each user.
|
515
|
+
Order results differently for each user. For example, show a user’s previously purchased products before other results.
|
514
516
|
|
515
517
|
```ruby
|
516
518
|
class Product < ActiveRecord::Base
|
@@ -537,7 +539,7 @@ Autocomplete predicts what a user will type, making the search experience faster
|
|
537
539
|
|
538
540
|
**Note:** If you only have a few thousand records, don’t use Searchkick for autocomplete. It’s *much* faster to load all records into JavaScript and autocomplete there (eliminates network requests).
|
539
541
|
|
540
|
-
First, specify which fields use this feature.
|
542
|
+
First, specify which fields use this feature. This is necessary since autocomplete can increase the index size significantly, but don’t worry - this gives you blazing faster queries.
|
541
543
|
|
542
544
|
```ruby
|
543
545
|
class Book < ActiveRecord::Base
|
@@ -949,7 +951,7 @@ See the [complete list of analyzers](lib/searchkick/index.rb#L209).
|
|
949
951
|
|
950
952
|
## Deployment
|
951
953
|
|
952
|
-
Searchkick uses `ENV["ELASTICSEARCH_URL"]` for the Elasticsearch server.
|
954
|
+
Searchkick uses `ENV["ELASTICSEARCH_URL"]` for the Elasticsearch server. This defaults to `http://localhost:9200`.
|
953
955
|
|
954
956
|
### Heroku
|
955
957
|
|
@@ -1376,7 +1378,7 @@ Product.search "ah", misspellings: {prefix_length: 2} # ah, no aha
|
|
1376
1378
|
|
1377
1379
|
## Large Data Sets
|
1378
1380
|
|
1379
|
-
For large data sets, check out [Keeping Elasticsearch in Sync](https://www.elastic.co/blog/found-keeping-elasticsearch-in-sync).
|
1381
|
+
For large data sets, check out [Keeping Elasticsearch in Sync](https://www.elastic.co/blog/found-keeping-elasticsearch-in-sync). Searchkick will make this easy in the future.
|
1380
1382
|
|
1381
1383
|
## Testing
|
1382
1384
|
|
@@ -1476,7 +1478,7 @@ Before `0.3.0`, locations were indexed incorrectly. When upgrading, be sure to r
|
|
1476
1478
|
|
1477
1479
|
### Inconsistent Scores
|
1478
1480
|
|
1479
|
-
Due to the distributed nature of Elasticsearch, you can get incorrect results when the number of documents in the index is low.
|
1481
|
+
Due to the distributed nature of Elasticsearch, you can get incorrect results when the number of documents in the index is low. You can [read more about it here](https://www.elastic.co/blog/understanding-query-then-fetch-vs-dfs-query-then-fetch). To fix this, do:
|
1480
1482
|
|
1481
1483
|
```ruby
|
1482
1484
|
class Product < ActiveRecord::Base
|
data/lib/searchkick/version.rb
CHANGED
data/lib/searchkick.rb
CHANGED
@@ -12,6 +12,14 @@ require "searchkick/tasks"
|
|
12
12
|
require "searchkick/middleware"
|
13
13
|
require "searchkick/logging" if defined?(ActiveSupport::Notifications)
|
14
14
|
|
15
|
+
# background jobs
|
16
|
+
begin
|
17
|
+
require "active_job"
|
18
|
+
rescue LoadError
|
19
|
+
# do nothing
|
20
|
+
end
|
21
|
+
require "searchkick/reindex_v2_job" if defined?(ActiveJob)
|
22
|
+
|
15
23
|
module Searchkick
|
16
24
|
class Error < StandardError; end
|
17
25
|
class MissingIndexError < Error; end
|
@@ -152,13 +160,6 @@ module Searchkick
|
|
152
160
|
end
|
153
161
|
end
|
154
162
|
|
155
|
-
ActiveSupport.on_load(:active_job) do
|
156
|
-
require "searchkick/reindex_v2_job"
|
157
|
-
end
|
158
|
-
|
159
163
|
# TODO find better ActiveModel hook
|
160
164
|
ActiveModel::Callbacks.send(:include, Searchkick::Model)
|
161
|
-
|
162
|
-
ActiveSupport.on_load(:active_record) do
|
163
|
-
ActiveRecord::Base.send(:extend, Searchkick::Model)
|
164
|
-
end
|
165
|
+
ActiveRecord::Base.send(:extend, Searchkick::Model) if defined?(ActiveRecord)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|