searchkick 2.5.0 → 3.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 +4 -4
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.travis.yml +2 -11
- data/CHANGELOG.md +22 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +3 -3
- data/LICENSE.txt +1 -1
- data/README.md +68 -141
- data/Rakefile +0 -4
- data/benchmark/Gemfile +3 -2
- data/benchmark/{benchmark.rb → index.rb} +33 -31
- data/benchmark/search.rb +48 -0
- data/docs/Searchkick-3-Upgrade.md +57 -0
- data/lib/searchkick.rb +50 -27
- data/lib/searchkick/bulk_indexer.rb +168 -0
- data/lib/searchkick/bulk_reindex_job.rb +1 -1
- data/lib/searchkick/index.rb +122 -348
- data/lib/searchkick/index_options.rb +29 -26
- data/lib/searchkick/logging.rb +8 -7
- data/lib/searchkick/model.rb +37 -90
- data/lib/searchkick/multi_search.rb +6 -7
- data/lib/searchkick/query.rb +169 -166
- data/lib/searchkick/record_data.rb +133 -0
- data/lib/searchkick/record_indexer.rb +55 -0
- data/lib/searchkick/reindex_queue.rb +1 -1
- data/lib/searchkick/reindex_v2_job.rb +10 -13
- data/lib/searchkick/results.rb +14 -25
- data/lib/searchkick/tasks.rb +0 -4
- data/lib/searchkick/version.rb +1 -1
- data/searchkick.gemspec +3 -3
- data/test/boost_test.rb +3 -9
- data/test/geo_shape_test.rb +0 -4
- data/test/highlight_test.rb +28 -12
- data/test/index_test.rb +9 -10
- data/test/language_test.rb +16 -0
- data/test/marshal_test.rb +6 -1
- data/test/match_test.rb +9 -4
- data/test/model_test.rb +3 -5
- data/test/multi_search_test.rb +0 -7
- data/test/order_test.rb +1 -7
- data/test/pagination_test.rb +1 -1
- data/test/reindex_v2_job_test.rb +6 -11
- data/test/routing_test.rb +1 -1
- data/test/similar_test.rb +2 -2
- data/test/sql_test.rb +0 -31
- data/test/test_helper.rb +37 -23
- metadata +19 -26
- data/test/gemfiles/activerecord31.gemfile +0 -7
- data/test/gemfiles/activerecord32.gemfile +0 -7
- data/test/gemfiles/activerecord40.gemfile +0 -8
- data/test/gemfiles/activerecord41.gemfile +0 -8
- data/test/gemfiles/mongoid2.gemfile +0 -7
- data/test/gemfiles/mongoid3.gemfile +0 -6
- data/test/gemfiles/mongoid4.gemfile +0 -7
- data/test/records_test.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0114d21ec3a6707c49408e641fa27a5591cc9eca
|
4
|
+
data.tar.gz: d723af7de81aa5ff40818fcd229029724a0fcda7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04b026c1acdd413476a2099f7b0b335c207f286e4aadd9d323f0f5d8f5bc18cd15da2219040830a12f258dba497c9412510815fd2af70682e3579239caeaabba
|
7
|
+
data.tar.gz: e41240ef1831b869311c588a3a6d87c054607fedd2d3da3d56db4d220ae7c1038a317cb703f220b36f06c2ada8b99f2a34cd8e3b7f7c046d6ad2fb2115004a3c
|
data/.travis.yml
CHANGED
@@ -20,22 +20,13 @@ gemfile:
|
|
20
20
|
- test/gemfiles/mongoid5.gemfile
|
21
21
|
- test/gemfiles/mongoid6.gemfile
|
22
22
|
env:
|
23
|
-
- ELASTICSEARCH_VERSION=6.2.
|
23
|
+
- ELASTICSEARCH_VERSION=6.2.2
|
24
24
|
jdk: oraclejdk8
|
25
25
|
matrix:
|
26
26
|
include:
|
27
|
-
- gemfile: Gemfile
|
28
|
-
env: ELASTICSEARCH_VERSION=2.0.0
|
29
|
-
jdk: oraclejdk7
|
30
|
-
- gemfile: Gemfile
|
31
|
-
env: ELASTICSEARCH_VERSION=2.4.6
|
32
|
-
jdk: oraclejdk7
|
33
27
|
- gemfile: Gemfile
|
34
28
|
env: ELASTICSEARCH_VERSION=5.0.1
|
35
|
-
jdk: oraclejdk8
|
36
29
|
- gemfile: Gemfile
|
37
|
-
env: ELASTICSEARCH_VERSION=5.6.
|
38
|
-
jdk: oraclejdk8
|
30
|
+
env: ELASTICSEARCH_VERSION=5.6.7
|
39
31
|
- gemfile: Gemfile
|
40
32
|
env: ELASTICSEARCH_VERSION=6.0.0
|
41
|
-
jdk: oraclejdk8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 3.0.0
|
2
|
+
|
3
|
+
- Added support for Chinese
|
4
|
+
- Results can be marshaled by default (unless using `highlight` option)
|
5
|
+
|
6
|
+
Breaking changes
|
7
|
+
|
8
|
+
- Removed support for Elasticsearch 2
|
9
|
+
- Removed support for ActiveRecord < 4.2 and Mongoid < 5
|
10
|
+
- Types are no longer used
|
11
|
+
- The `_all` field is disabled by default in Elasticsearch 5
|
12
|
+
- Conversions are not stemmed by default
|
13
|
+
- An `ArgumentError` is raised instead of a warning when options are incompatible with the `body` option
|
14
|
+
- Removed `log` option from `boost_by`
|
15
|
+
- Removed `Model.enable_search_callbacks`, `Model.disable_search_callbacks`, and `Model.search_callbacks?`
|
16
|
+
- Removed `reindex_async` method, as `reindex` now defaults to callbacks mode specified on the model
|
17
|
+
- Removed `async` option from `record.reindex`
|
18
|
+
- Removed `search_hit` method - use `with_hit` instead
|
19
|
+
- Removed `each_with_hit` - use `with_hit.each` instead
|
20
|
+
- Removed `with_details` - use `with_highlights` instead
|
21
|
+
- Bumped default `limit` to 10,000
|
22
|
+
|
1
23
|
## 2.5.0
|
2
24
|
|
3
25
|
- Try requests 3 times before raising error
|
data/CONTRIBUTING.md
CHANGED
@@ -29,7 +29,7 @@ Product.search("something", debug: true)
|
|
29
29
|
|
30
30
|
If the above steps don’t help, create an issue.
|
31
31
|
|
32
|
-
-
|
32
|
+
- Recreate the problem by forking [this gist](https://gist.github.com/ankane/f80b0923d9ae2c077f41997f7b704e5c). Include a link to your gist and the output in the issue.
|
33
33
|
- For exceptions, include the complete backtrace.
|
34
34
|
|
35
35
|
## Pull Requests
|
data/Gemfile
CHANGED
@@ -4,13 +4,13 @@ source "https://rubygems.org"
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
gem "sqlite3"
|
7
|
-
gem "activerecord", "~> 5.
|
7
|
+
gem "activerecord", "~> 5.2.0.rc1"
|
8
8
|
gem "gemoji-parser"
|
9
9
|
gem "typhoeus"
|
10
|
-
gem "activejob"
|
10
|
+
gem "activejob", "~> 5.2.0.rc1"
|
11
11
|
gem "redis"
|
12
12
|
gem "connection_pool"
|
13
13
|
|
14
14
|
# kaminari
|
15
|
-
gem "actionpack"
|
15
|
+
gem "actionpack", "~> 5.2.0.rc1"
|
16
16
|
gem "kaminari"
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
:rocket: Intelligent search made easy
|
4
4
|
|
5
|
-
Searchkick learns what
|
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
|
|
@@ -27,6 +27,12 @@ Plus:
|
|
27
27
|
|
28
28
|
[](https://travis-ci.org/ankane/searchkick)
|
29
29
|
|
30
|
+
---
|
31
|
+
|
32
|
+
Does your startup use Searchkick? Want a free hour of advising? Fill out [this application](https://goo.gl/forms/Or1HQTRb2rgQCNtd2). I’ll reach out to a few companies.
|
33
|
+
|
34
|
+
---
|
35
|
+
|
30
36
|
## Contents
|
31
37
|
|
32
38
|
- [Getting Started](#getting-started)
|
@@ -39,6 +45,10 @@ Plus:
|
|
39
45
|
- [Elasticsearch DSL](#advanced)
|
40
46
|
- [Reference](#reference)
|
41
47
|
|
48
|
+
**Searchkick 3.0 was recently released!** See [how to upgrade](docs/Searchkick-3-Upgrade.md)
|
49
|
+
|
50
|
+
Thinking of upgrading from Elasticsearch 5 to 6? [Read this first](#elasticsearch-5-to-6-upgrade)
|
51
|
+
|
42
52
|
## Getting Started
|
43
53
|
|
44
54
|
[Install Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html). For Homebrew, use:
|
@@ -54,7 +64,7 @@ Add this line to your application’s Gemfile:
|
|
54
64
|
gem 'searchkick'
|
55
65
|
```
|
56
66
|
|
57
|
-
The latest version works with Elasticsearch
|
67
|
+
The latest version works with Elasticsearch 5 and 6. For Elasticsearch 2, use version 2.5.0 and [this readme](https://github.com/ankane/searchkick/blob/v2.5.0/README.md).
|
58
68
|
|
59
69
|
Add searchkick to models you want to search.
|
60
70
|
|
@@ -73,7 +83,7 @@ Product.reindex
|
|
73
83
|
And to query, use:
|
74
84
|
|
75
85
|
```ruby
|
76
|
-
products = Product.search("apples"
|
86
|
+
products = Product.search("apples")
|
77
87
|
products.each do |product|
|
78
88
|
puts product.name
|
79
89
|
end
|
@@ -289,6 +299,14 @@ end
|
|
289
299
|
|
290
300
|
[See the list of stemmers](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html)
|
291
301
|
|
302
|
+
For Chinese, install the [elasticsearch-analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik) and use:
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
class Product < ApplicationRecord
|
306
|
+
searchkick language: "chinese"
|
307
|
+
end
|
308
|
+
```
|
309
|
+
|
292
310
|
### Synonyms
|
293
311
|
|
294
312
|
```ruby
|
@@ -492,7 +510,7 @@ There are four strategies for keeping the index synced with your database.
|
|
492
510
|
end
|
493
511
|
```
|
494
512
|
|
495
|
-
|
513
|
+
Jobs are added to a queue named `searchkick`.
|
496
514
|
|
497
515
|
3. Queuing
|
498
516
|
|
@@ -535,7 +553,7 @@ class Image < ApplicationRecord
|
|
535
553
|
after_commit :reindex_product
|
536
554
|
|
537
555
|
def reindex_product
|
538
|
-
product.reindex
|
556
|
+
product.reindex
|
539
557
|
end
|
540
558
|
end
|
541
559
|
```
|
@@ -563,7 +581,7 @@ Searchkick can use conversion data to learn what users are looking for. If a use
|
|
563
581
|
|
564
582
|
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.
|
565
583
|
|
566
|
-
|
584
|
+
Searchkick automatically treats `apple` and `APPLE` the same.
|
567
585
|
|
568
586
|
Next, add conversions to the index.
|
569
587
|
|
@@ -571,7 +589,7 @@ Next, add conversions to the index.
|
|
571
589
|
class Product < ApplicationRecord
|
572
590
|
has_many :searches, class_name: "Searchjoy::Search", as: :convertable
|
573
591
|
|
574
|
-
searchkick conversions: [
|
592
|
+
searchkick conversions: [:conversions] # name of field
|
575
593
|
|
576
594
|
def search_data
|
577
595
|
{
|
@@ -767,63 +785,6 @@ For other aggregation types, including sub-aggregations, use `body_options`:
|
|
767
785
|
Product.search "orange", body_options: {aggs: {price: {histogram: {field: :price, interval: 10}}}
|
768
786
|
```
|
769
787
|
|
770
|
-
#### Moving From Facets
|
771
|
-
|
772
|
-
1. Replace `facets` with `aggs` in searches. **Note:** Stats facets are not supported at this time.
|
773
|
-
|
774
|
-
```ruby
|
775
|
-
products = Product.search "chuck taylor", facets: [:brand]
|
776
|
-
# to
|
777
|
-
products = Product.search "chuck taylor", aggs: [:brand]
|
778
|
-
```
|
779
|
-
|
780
|
-
2. Replace the `facets` method with `aggs` for results.
|
781
|
-
|
782
|
-
```ruby
|
783
|
-
products.facets
|
784
|
-
# to
|
785
|
-
products.aggs
|
786
|
-
```
|
787
|
-
|
788
|
-
The keys in results differ slightly. Instead of:
|
789
|
-
|
790
|
-
```json
|
791
|
-
{
|
792
|
-
"_type":"terms",
|
793
|
-
"missing":0,
|
794
|
-
"total":45,
|
795
|
-
"other":34,
|
796
|
-
"terms":[
|
797
|
-
{"term":14.0,"count":11}
|
798
|
-
]
|
799
|
-
}
|
800
|
-
```
|
801
|
-
|
802
|
-
You get:
|
803
|
-
|
804
|
-
```json
|
805
|
-
{
|
806
|
-
"doc_count":45,
|
807
|
-
"doc_count_error_upper_bound":0,
|
808
|
-
"sum_other_doc_count":34,
|
809
|
-
"buckets":[
|
810
|
-
{"key":14.0,"doc_count":11}
|
811
|
-
]
|
812
|
-
}
|
813
|
-
```
|
814
|
-
|
815
|
-
Update your application to handle this.
|
816
|
-
|
817
|
-
3. By default, `where` conditions apply to aggregations. This is equivalent to `smart_facets: true`. If you have `smart_facets: true`, you can remove it. If this is not desired, set `smart_aggs: false`.
|
818
|
-
|
819
|
-
4. If you have any range facets with dates, change the key from `ranges` to `date_ranges`.
|
820
|
-
|
821
|
-
```ruby
|
822
|
-
facets: {date_field: {ranges: date_ranges}}
|
823
|
-
# to
|
824
|
-
aggs: {date_field: {date_ranges: date_ranges}}
|
825
|
-
```
|
826
|
-
|
827
788
|
### Highlight
|
828
789
|
|
829
790
|
Specify which fields to index with highlighting.
|
@@ -837,23 +798,21 @@ end
|
|
837
798
|
Highlight the search query in the results.
|
838
799
|
|
839
800
|
```ruby
|
840
|
-
bands = Band.search "cinema",
|
801
|
+
bands = Band.search "cinema", highlight: true
|
841
802
|
```
|
842
803
|
|
843
|
-
**Note:** The `fields` option is required, unless highlight options are given - see below.
|
844
|
-
|
845
804
|
View the highlighted fields with:
|
846
805
|
|
847
806
|
```ruby
|
848
|
-
bands.each do |band|
|
849
|
-
|
807
|
+
bands.with_highlights.each do |band, highlights|
|
808
|
+
highlights[:name] # "Two Door <em>Cinema</em> Club"
|
850
809
|
end
|
851
810
|
```
|
852
811
|
|
853
812
|
To change the tag, use:
|
854
813
|
|
855
814
|
```ruby
|
856
|
-
Band.search "cinema",
|
815
|
+
Band.search "cinema", highlight: {tag: "<strong>"}
|
857
816
|
```
|
858
817
|
|
859
818
|
To highlight and search different fields, use:
|
@@ -862,7 +821,16 @@ To highlight and search different fields, use:
|
|
862
821
|
Band.search "cinema", fields: [:name], highlight: {fields: [:description]}
|
863
822
|
```
|
864
823
|
|
865
|
-
|
824
|
+
By default, the entire field is highlighted. To get small snippets instead, use:
|
825
|
+
|
826
|
+
```ruby
|
827
|
+
bands = Band.search "cinema", highlight: {fragment_size: 20}
|
828
|
+
bands.with_highlights(multiple: true).each do |band, highlights|
|
829
|
+
highlights[:name].join(" and ")
|
830
|
+
end
|
831
|
+
```
|
832
|
+
|
833
|
+
Additional options can be specified for each field:
|
866
834
|
|
867
835
|
```ruby
|
868
836
|
Band.search "cinema", fields: [:name], highlight: {fields: {name: {fragment_size: 200}}}
|
@@ -966,7 +934,7 @@ Not touching the query shape
|
|
966
934
|
Restaurant.search "burger", where: {bounds: {geo_shape: {type: "envelope", relation: "disjoint", coordinates: [{lat: 38, lon: -123}, {lat: 37, lon: -122}]}}}
|
967
935
|
```
|
968
936
|
|
969
|
-
Containing the query shape
|
937
|
+
Containing the query shape
|
970
938
|
|
971
939
|
```ruby
|
972
940
|
Restaurant.search "fries", where: {bounds: {geo_shape: {type: "envelope", relation: "contains", coordinates: [{lat: 38, lon: -123}, {lat: 37, lon: -122}]}}}
|
@@ -1093,12 +1061,6 @@ heroku run rake searchkick:reindex CLASS=Product
|
|
1093
1061
|
|
1094
1062
|
### Amazon Elasticsearch Service
|
1095
1063
|
|
1096
|
-
Include `elasticsearch 1.0.15` or greater in your Gemfile.
|
1097
|
-
|
1098
|
-
```ruby
|
1099
|
-
gem 'elasticsearch', '>= 1.0.15'
|
1100
|
-
```
|
1101
|
-
|
1102
1064
|
Create an initializer `config/initializers/elasticsearch.rb` with:
|
1103
1065
|
|
1104
1066
|
```ruby
|
@@ -1108,7 +1070,7 @@ ENV["ELASTICSEARCH_URL"] = "https://es-domain-1234.us-east-1.es.amazonaws.com"
|
|
1108
1070
|
To use signed request, include in your Gemfile:
|
1109
1071
|
|
1110
1072
|
```ruby
|
1111
|
-
gem 'faraday_middleware-aws-
|
1073
|
+
gem 'faraday_middleware-aws-sigv4'
|
1112
1074
|
```
|
1113
1075
|
|
1114
1076
|
and add to your initializer:
|
@@ -1147,10 +1109,6 @@ Create an initializer `config/initializers/elasticsearch.rb` with multiple hosts
|
|
1147
1109
|
|
1148
1110
|
```ruby
|
1149
1111
|
ENV["ELASTICSEARCH_URL"] = "http://localhost:9200,http://localhost:9201"
|
1150
|
-
|
1151
|
-
Searchkick.client_options = {
|
1152
|
-
retry_on_failure: true
|
1153
|
-
}
|
1154
1112
|
```
|
1155
1113
|
|
1156
1114
|
See [elasticsearch-transport](https://github.com/elastic/elasticsearch-ruby/blob/master/elasticsearch-transport) for a complete list of options.
|
@@ -1192,7 +1150,7 @@ gem 'typhoeus'
|
|
1192
1150
|
To reduce log noise, create an initializer with:
|
1193
1151
|
|
1194
1152
|
```ruby
|
1195
|
-
Ethon.logger = Logger.new(
|
1153
|
+
Ethon.logger = Logger.new(nil)
|
1196
1154
|
```
|
1197
1155
|
|
1198
1156
|
If you run into issues on Windows, check out [this post](https://www.rastating.com/fixing-issues-in-typhoeus-and-httparty-on-windows/).
|
@@ -1217,7 +1175,7 @@ class Product < ApplicationRecord
|
|
1217
1175
|
end
|
1218
1176
|
```
|
1219
1177
|
|
1220
|
-
**Note:** Non-string fields
|
1178
|
+
**Note:** Non-string fields are always filterable and should not be passed to this option.
|
1221
1179
|
|
1222
1180
|
### Parallel Reindexing
|
1223
1181
|
|
@@ -1535,8 +1493,6 @@ Reindex one record
|
|
1535
1493
|
```ruby
|
1536
1494
|
product = Product.find(1)
|
1537
1495
|
product.reindex
|
1538
|
-
# or to reindex in the background
|
1539
|
-
product.reindex_async
|
1540
1496
|
```
|
1541
1497
|
|
1542
1498
|
Reindex multiple records
|
@@ -1666,7 +1622,7 @@ Eager load different associations by model
|
|
1666
1622
|
Searchkick.search("*", index_name: [Product, Store], model_includes: {Product => [:store], Store => [:product]})
|
1667
1623
|
```
|
1668
1624
|
|
1669
|
-
Run additional scopes on results
|
1625
|
+
Run additional scopes on results
|
1670
1626
|
|
1671
1627
|
```ruby
|
1672
1628
|
Product.search "milk", scope_results: ->(r) { r.with_attached_images }
|
@@ -1804,9 +1760,9 @@ RSpec.configure do |config|
|
|
1804
1760
|
end
|
1805
1761
|
|
1806
1762
|
config.around(:each, search: true) do |example|
|
1807
|
-
Searchkick.
|
1808
|
-
|
1809
|
-
|
1763
|
+
Searchkick.callbacks(true) do
|
1764
|
+
example.run
|
1765
|
+
end
|
1810
1766
|
end
|
1811
1767
|
end
|
1812
1768
|
```
|
@@ -1858,60 +1814,27 @@ Searchkick.index_suffix = ENV["TEST_ENV_NUMBER"]
|
|
1858
1814
|
|
1859
1815
|
Check out [this great post](https://www.tiagoamaro.com.br/2014/12/11/multi-tenancy-with-searchkick/) on the [Apartment](https://github.com/influitive/apartment) gem. Follow a similar pattern if you use another gem.
|
1860
1816
|
|
1861
|
-
##
|
1862
|
-
|
1863
|
-
View the [changelog](https://github.com/ankane/searchkick/blob/master/CHANGELOG.md).
|
1864
|
-
|
1865
|
-
Important notes are listed below.
|
1866
|
-
|
1867
|
-
### 2.0.0
|
1868
|
-
|
1869
|
-
- Added support for `reindex` on associations
|
1870
|
-
|
1871
|
-
#### Breaking Changes
|
1872
|
-
|
1873
|
-
- Removed support for Elasticsearch 1 as it reaches [end of life](https://www.elastic.co/support/eol)
|
1874
|
-
- Removed facets, legacy options, and legacy methods
|
1875
|
-
- Invalid options now throw an `ArgumentError`
|
1876
|
-
- The `query` and `json` options have been removed in favor of `body`
|
1877
|
-
- The `include` option has been removed in favor of `includes`
|
1878
|
-
- The `personalize` option has been removed in favor of `boost_where`
|
1879
|
-
- The `partial` option has been removed in favor of `operator`
|
1880
|
-
- Renamed `select_v2` to `select` (legacy `select` no longer available)
|
1881
|
-
- The `_all` field is disabled if `searchable` option is used (for performance)
|
1882
|
-
- The `partial_reindex(:method_name)` method has been replaced with `reindex(:method_name)`
|
1883
|
-
- The `unsearchable` and `only_analyzed` options have been removed in favor of `searchable` and `filterable`
|
1884
|
-
- `load: false` no longer returns an array in Elasticsearch 2
|
1885
|
-
|
1886
|
-
### 1.0.0
|
1887
|
-
|
1888
|
-
- Added support for Elasticsearch 2.0
|
1889
|
-
- Facets are deprecated in favor of [aggregations](#aggregations) - see [how to upgrade](#moving-from-facets)
|
1890
|
-
|
1891
|
-
#### Breaking Changes
|
1892
|
-
|
1893
|
-
- **ActiveRecord 4.1+ and Mongoid 3+:** Attempting to reindex with a scope now throws a `Searchkick::DangerousOperation` error to keep your from accidentally recreating your index with only a few records.
|
1894
|
-
|
1895
|
-
```ruby
|
1896
|
-
Product.where(color: "brandy").reindex # error!
|
1897
|
-
```
|
1817
|
+
## Elasticsearch 5 to 6 Upgrade
|
1898
1818
|
|
1899
|
-
|
1819
|
+
Elasticsearch 6 removes the ability to reindex with the `_all` field. Before you upgrade, we recommend disabling this field manually and specifying default fields on your models.
|
1900
1820
|
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
- [Transpositions](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) are enabled by default for misspellings. Use `misspellings: {transpositions: false}` to disable.
|
1907
|
-
|
1908
|
-
### 0.6.0 and 0.7.0
|
1909
|
-
|
1910
|
-
If running Searchkick `0.6.0` or `0.7.0` and Elasticsearch `0.90`, we recommend upgrading to Searchkick `0.6.1` or `0.7.1` to fix an issue that causes downtime when reindexing.
|
1821
|
+
```ruby
|
1822
|
+
class Product < ApplicationRecord
|
1823
|
+
searchkick _all: false, default_fields: [:name]
|
1824
|
+
end
|
1825
|
+
```
|
1911
1826
|
|
1912
|
-
|
1827
|
+
If you need search across multiple fields, we recommend creating a similar field in your search data.
|
1913
1828
|
|
1914
|
-
|
1829
|
+
```ruby
|
1830
|
+
class Product < ApplicationRecord
|
1831
|
+
def search_data
|
1832
|
+
{
|
1833
|
+
all: [name, size, quantity].join(" ")
|
1834
|
+
}
|
1835
|
+
end
|
1836
|
+
end
|
1837
|
+
```
|
1915
1838
|
|
1916
1839
|
## Elasticsearch Gotchas
|
1917
1840
|
|
@@ -1936,6 +1859,10 @@ end
|
|
1936
1859
|
|
1937
1860
|
For convenience, this is set by default in the test environment.
|
1938
1861
|
|
1862
|
+
## History
|
1863
|
+
|
1864
|
+
View the [changelog](https://github.com/ankane/searchkick/blob/master/CHANGELOG.md).
|
1865
|
+
|
1939
1866
|
## Thanks
|
1940
1867
|
|
1941
1868
|
Thanks to Karel Minarik for [Elasticsearch Ruby](https://github.com/elasticsearch/elasticsearch-ruby) and [Tire](https://github.com/karmi/retire), Jaroslav Kalistsuk for [zero downtime reindexing](https://gist.github.com/jarosan/3124884), and Alex Leschenko for [Elasticsearch autocomplete](https://github.com/leschenko/elasticsearch_autocomplete).
|