searchkick 0.7.6 → 0.7.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d9d6517d9d49a09f8827ea95a866e4a162fa7f3
4
- data.tar.gz: cb53edf08c5f05e95e6bb11aa2e00f010f6e2043
3
+ metadata.gz: 4a044b56c37732d857fe1dfa7109dc1b87259f15
4
+ data.tar.gz: 6fa27e15c4317b20e87f81c22e0ca0f3e69d68cc
5
5
  SHA512:
6
- metadata.gz: 3a9fb661de8eaa36d5f1c979ee1bb0a3779716b4983e17d94de72883fd1a549c874cbd2a41f8498b7f4110e5d62ed7511f3d873df9a42d51aa590cf55156d72f
7
- data.tar.gz: 000f1e7fb07a5d00659f21a8116e8fd57dcaf6b41adcc261d7687e6cccccd2edb811738c7e3552f0ac1c594dffd818ae4966cdda36ed8fe334843df1350e4137
6
+ metadata.gz: 6669b630d244570056a3c2373dda6d99c0c59e25af9c4a716401b9b3178b8867d572a7b553156d69e0b7728fa2ba24e256d347ef39597033d845b9d15e05e7d6
7
+ data.tar.gz: b351f5f4d832e80dd9e16acbbebbeb2db89a9ac0ea470394391f033ab66da728e811ee9b25f99de6bb0a65c6bedf5d2e572b10eef879d4f225d488f2cf2b3453
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.7.7
2
+
3
+ - Added support for automatic failover
4
+ - Fixed default operator for partial queries
5
+
1
6
  ## 0.7.6
2
7
 
3
8
  - Added `stats` option to facets
data/README.md CHANGED
@@ -45,7 +45,7 @@ Add this line to your application’s Gemfile:
45
45
  gem "searchkick"
46
46
  ```
47
47
 
48
- For Elasticsearch 0.90, use version `0.6.3`.
48
+ For Elasticsearch 0.90, use version `0.6.3` and [this readme](https://github.com/ankane/searchkick/blob/v0.6.3/README.md).
49
49
 
50
50
  Add searchkick to models you want to search.
51
51
 
@@ -443,7 +443,7 @@ price_ranges = [{to: 20}, {from: 20, to: 50}, {from: 50}]
443
443
  Product.search "*", facets: {price: {ranges: price_ranges}}
444
444
  ```
445
445
 
446
- Use the `stats` option to get to max, min, mean, and total scores for each facet [master]
446
+ Use the `stats` option to get to max, min, mean, and total scores for each facet
447
447
 
448
448
  ```ruby
449
449
  Product.search "*", facets: {store_id: {stats: true}}
@@ -580,6 +580,16 @@ Then deploy and reindex:
580
580
  rake searchkick:reindex CLASS=Product
581
581
  ```
582
582
 
583
+ ### Automatic Failover
584
+
585
+ Create an initializer `config/initializers/elasticsearch.rb` with multiple hosts:
586
+
587
+ ```ruby
588
+ Searchkick.client = Elasticsearch::Client.new(hosts: ["localhost:9200", "localhost:9201"], retry_on_failure: true)
589
+ ```
590
+
591
+ See [elasticsearch-transport](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-transport) for a complete list of options.
592
+
583
593
  ## Advanced
584
594
 
585
595
  Prefer to use the [Elasticsearch DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html) but still want awesome features like zero-downtime reindexing?
data/lib/searchkick.rb CHANGED
@@ -21,6 +21,10 @@ module Searchkick
21
21
  @client ||= Elasticsearch::Client.new(url: ENV["ELASTICSEARCH_URL"])
22
22
  end
23
23
 
24
+ def self.client=(client)
25
+ @client = client
26
+ end
27
+
24
28
  @callbacks = true
25
29
 
26
30
  def self.enable_callbacks
@@ -74,13 +74,13 @@ module Searchkick
74
74
  else
75
75
  queries = []
76
76
  fields.each do |field|
77
+ shared_options = {
78
+ fields: [field],
79
+ query: term,
80
+ use_dis_max: false,
81
+ operator: operator
82
+ }
77
83
  if field == "_all" or field.end_with?(".analyzed")
78
- shared_options = {
79
- fields: [field],
80
- query: term,
81
- use_dis_max: false,
82
- operator: operator
83
- }
84
84
  shared_options[:cutoff_frequency] = 0.001 unless operator == "and"
85
85
  queries.concat [
86
86
  {multi_match: shared_options.merge(boost: 10, analyzer: "searchkick_search")},
@@ -95,13 +95,7 @@ module Searchkick
95
95
  end
96
96
  else
97
97
  analyzer = field.match(/\.word_(start|middle|end)\z/) ? "searchkick_word_search" : "searchkick_autocomplete_search"
98
- queries << {
99
- multi_match: {
100
- fields: [field],
101
- query: term,
102
- analyzer: analyzer
103
- }
104
- }
98
+ queries << {multi_match: shared_options.merge(analyzer: analyzer)}
105
99
  end
106
100
  end
107
101
 
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
@@ -52,4 +52,9 @@ class TestAutocomplete < Minitest::Unit::TestCase
52
52
  assert_search "rld men ego", ["Where in the World is Carmen San Diego"], fields: [{name: :word_end}]
53
53
  end
54
54
 
55
+ def test_word_start_multiple_words
56
+ store_names ["Dark Grey", "Dark Blue"]
57
+ assert_search "dark grey", ["Dark Grey"], fields: [{name: :word_start}]
58
+ end
59
+
55
60
  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: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-21 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel