Commit 9bdf952e20365654d5544384758a63ea8e5a3351
1 parent
4f130606
Exists in
master
and in
21 other branches
Added similarity option
Showing
3 changed files
with
13 additions
and
0 deletions
Show diff stats
CHANGELOG.md
README.md
... | ... | @@ -1155,6 +1155,14 @@ class Product < ActiveRecord::Base |
1155 | 1155 | end |
1156 | 1156 | ``` |
1157 | 1157 | |
1158 | +Use [Okapi BM25](https://www.elastic.co/guide/en/elasticsearch/guide/current/pluggable-similarites.html) for ranking [master] | |
1159 | + | |
1160 | +```ruby | |
1161 | +class Product < ActiveRecord::Base | |
1162 | + searchkick similarity: "BM25" | |
1163 | +end | |
1164 | +``` | |
1165 | + | |
1158 | 1166 | Change import batch size |
1159 | 1167 | |
1160 | 1168 | ```ruby | ... | ... |
lib/searchkick/index.rb
... | ... | @@ -353,6 +353,10 @@ module Searchkick |
353 | 353 | settings.merge!(number_of_shards: 1, number_of_replicas: 0) |
354 | 354 | end |
355 | 355 | |
356 | + if options[:similarity] | |
357 | + settings[:similarity] = {default: {type: options[:similarity]}} | |
358 | + end | |
359 | + | |
356 | 360 | settings.deep_merge!(options[:settings] || {}) |
357 | 361 | |
358 | 362 | # synonyms | ... | ... |