searchkick 4.4.4 → 4.5.0

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
  SHA256:
3
- metadata.gz: 864e600f47d8f3cc55c5664f04b71a1eb054bdad20acd5eb206a77bdeed03503
4
- data.tar.gz: 2dcd69102ab91f46209dd345cf180309729d470423fb0832fa8e6ed0772cfa45
3
+ metadata.gz: 62e2797b9ad2290378febadeaab675b745b0318cd86a8219cada4774b529e290
4
+ data.tar.gz: 8f0956287e802ce93a67940f6283f914b58b38aee2240f3ef101ae08e7428966
5
5
  SHA512:
6
- metadata.gz: c687faaae288a53c7ec5260c501c390c0c27cef372cb76dea4caeaa4bdbd6554ccf627ba10a82fe8202f236d84ee00e8872632316f66e0cc89fe4f3900e017a0
7
- data.tar.gz: c61486f67dc88dee390022aacb91f45278559d23cf62dd7a9f9468aa2e317b0d643a7f500162608e81496c750987e39391b1200a1d2f0528985187b32b094f53
6
+ metadata.gz: 34a3bf2400766d7a2e95c3ba430a42c08dc1cfeb6c2d26b4d6d2a04828fd5ee296f3b121b076f00502f7c0c849ff27e1e622635a70885ef7f1336f0b4b8709de
7
+ data.tar.gz: 1c190e32fa87aa03a025a349dfc200ced4c28069c524acaa7b3c220628c58b9da2742ae4c924a87bc354f920a7486cae176d2bd7078a72a98568a068b20df290
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 4.5.0 (2021-06-07)
2
+
3
+ - Added experimental support for OpenSearch
4
+ - Added support for synonyms in Japanese
5
+
1
6
  ## 4.4.4 (2021-03-12)
2
7
 
3
8
  - Fixed `too_long_frame_exception` with `scroll` method
data/lib/searchkick.rb CHANGED
@@ -74,11 +74,24 @@ module Searchkick
74
74
  (defined?(@search_timeout) && @search_timeout) || timeout
75
75
  end
76
76
 
77
+ # private
78
+ def self.server_info
79
+ @server_info ||= client.info
80
+ end
81
+
77
82
  def self.server_version
78
- @server_version ||= client.info["version"]["number"]
83
+ @server_version ||= server_info["version"]["number"]
84
+ end
85
+
86
+ def self.opensearch?
87
+ unless defined?(@opensearch)
88
+ @opensearch = server_info["version"]["distribution"] == "opensearch"
89
+ end
90
+ @opensearch
79
91
  end
80
92
 
81
93
  def self.server_below?(version)
94
+ server_version = opensearch? ? "7.10.2" : self.server_version
82
95
  Gem::Version.new(server_version.split("-")[0]) < Gem::Version.new(version.split("-")[0])
83
96
  end
84
97
 
@@ -235,6 +235,27 @@ module Searchkick
235
235
  type: "kuromoji"
236
236
  }
237
237
  )
238
+ when "japanese2"
239
+ analyzer = {
240
+ type: "custom",
241
+ tokenizer: "kuromoji_tokenizer",
242
+ filter: [
243
+ "kuromoji_baseform",
244
+ "kuromoji_part_of_speech",
245
+ "cjk_width",
246
+ "ja_stop",
247
+ "searchkick_stemmer",
248
+ "lowercase"
249
+ ]
250
+ }
251
+ settings[:analysis][:analyzer].merge!(
252
+ default_analyzer => analyzer.deep_dup,
253
+ searchkick_search: analyzer.deep_dup,
254
+ searchkick_search2: analyzer.deep_dup
255
+ )
256
+ settings[:analysis][:filter][:searchkick_stemmer] = {
257
+ type: "kuromoji_stemmer"
258
+ }
238
259
  when "korean"
239
260
  settings[:analysis][:analyzer].merge!(
240
261
  default_analyzer => {
@@ -512,8 +533,18 @@ module Searchkick
512
533
  end
513
534
  settings[:analysis][:filter][:searchkick_synonym_graph] = synonym_graph
514
535
 
515
- [:searchkick_search2, :searchkick_word_search].each do |analyzer|
516
- settings[:analysis][:analyzer][analyzer][:filter].insert(2, "searchkick_synonym_graph")
536
+ if options[:language] == "japanese2"
537
+ [:searchkick_search, :searchkick_search2].each do |analyzer|
538
+ settings[:analysis][:analyzer][analyzer][:filter].insert(4, "searchkick_synonym_graph")
539
+ end
540
+ else
541
+ [:searchkick_search2, :searchkick_word_search].each do |analyzer|
542
+ unless settings[:analysis][:analyzer][analyzer].key?(:filter)
543
+ raise Searchkick::Error, "Search synonyms are not supported yet for language"
544
+ end
545
+
546
+ settings[:analysis][:analyzer][analyzer][:filter].insert(2, "searchkick_synonym_graph")
547
+ end
517
548
  end
518
549
  end
519
550
  end
@@ -353,8 +353,8 @@ module Searchkick
353
353
  shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" || field_misspellings == false || (!below73? && !track_total_hits?)
354
354
  qs << shared_options.merge(analyzer: "searchkick_search")
355
355
 
356
- # searchkick_search and searchkick_search2 are the same for ukrainian
357
- unless %w(japanese korean polish ukrainian vietnamese).include?(searchkick_options[:language])
356
+ # searchkick_search and searchkick_search2 are the same for some languages
357
+ unless %w(japanese japanese2 korean polish ukrainian vietnamese).include?(searchkick_options[:language])
358
358
  qs << shared_options.merge(analyzer: "searchkick_search2")
359
359
  end
360
360
  exclude_analyzer = "searchkick_search2"
@@ -231,7 +231,7 @@ module Searchkick
231
231
  index_alias = index.split("_")[0..-2].join("_")
232
232
  Array((options[:index_mapping] || {})[index_alias])
233
233
  end
234
- raise Searchkick::Error, "Unknown model for index: #{index}" unless models.any?
234
+ raise Searchkick::Error, "Unknown model for index: #{index}. Pass the `models` option to the search method." unless models.any?
235
235
  index_models[index] = models
236
236
  end
237
237
 
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "4.4.4"
2
+ VERSION = "4.5.0"
3
3
  end
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: 4.4.4
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel