searchkick 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: ff1b17b6561440bad2ebe3c20d1606b13d579310
4
- data.tar.gz: 50475abfd988e11bca0b04385a4ec264bac80467
3
+ metadata.gz: 32cdf7dc806463087e8de7a1178b759b18621a3e
4
+ data.tar.gz: 354388509186cbd11616c958832182a892aacff9
5
5
  SHA512:
6
- metadata.gz: 19e25e2f81fb811f7bf1964cb59a5deccfc6386d10640279bfe6cfb7bb81a1611691ebd6ccb8879c7dcbec4f530d5ccf2fae089e19cc8f783409985092d2315b
7
- data.tar.gz: be76d99160e570515a3120ecb517a6faef29f2b3b95eb4ebc6556cbe2839d3554faa7295ff72ccc14caf82fb817b65e2286a74377fd95137d68c6666383bc26f
6
+ metadata.gz: 0154a4d77e5c9308a26c8524db04dbbe75b471ab5875835cb1d0c0594e0543e1e7bd9bb8f31384eb166bb513af6faede705d11964942674ec9452df7b113aac3
7
+ data.tar.gz: f5477b6069d310f813a2e0f84a6452920583458ba4ded63cc973976181dcf033271d90e3d30e5d7c1edbc3288bc4516adcbaee29dcbb12c96ebb7639e9c263c5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.3
2
+
3
+ - Better error messages
4
+ - Added where: {field: nil} queries
5
+
1
6
  ## 0.3.2
2
7
 
3
8
  - Added support for single table inheritance
data/README.md CHANGED
@@ -360,7 +360,7 @@ class City < ActiveRecord::Base
360
360
  searchkick locations: ["location"]
361
361
 
362
362
  def search_data
363
- to_hash.merge location: [latitude, longitude]
363
+ attributes.merge location: [latitude, longitude]
364
364
  end
365
365
  end
366
366
  ```
@@ -53,7 +53,7 @@ module Searchkick
53
53
 
54
54
  # hack to prevent generator field doesn't exist error
55
55
  (options[:suggest] || []).map(&:to_s).each do |field|
56
- source[field] = "a" if !source[field]
56
+ source[field] = nil if !source[field]
57
57
  end
58
58
 
59
59
  # locations
@@ -218,7 +218,11 @@ module Searchkick
218
218
  end
219
219
  end
220
220
  else
221
- filters << {term: {field => value}}
221
+ if value.nil?
222
+ filters << {missing: {"field" => field, existence: true, null_value: true}}
223
+ else
224
+ filters << {term: {field => value}}
225
+ end
222
226
  end
223
227
  end
224
228
  end
@@ -291,7 +295,18 @@ module Searchkick
291
295
  tire_options = {load: load, payload: payload, size: per_page, from: offset}
292
296
  tire_options[:type] = document_type if self != searchkick_klass
293
297
  search = Tire::Search::Search.new(index_name, tire_options)
294
- response = search.json
298
+ begin
299
+ response = search.json
300
+ rescue Tire::Search::SearchRequestFailed => e
301
+ status_code = e.message[0..3].to_i
302
+ if status_code == 404
303
+ raise "Index missing - run #{searchkick_klass.name}.reindex"
304
+ elsif status_code == 500 and e.message.include?("IllegalArgumentException[minimumSimilarity >= 1]")
305
+ raise "Upgrade Elasticsearch to 0.90.0 or greater"
306
+ else
307
+ raise e
308
+ end
309
+ end
295
310
 
296
311
  # apply facet limit in client due to
297
312
  # https://github.com/elasticsearch/elasticsearch/issues/1305
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/test/sql_test.rb CHANGED
@@ -75,6 +75,14 @@ class TestSql < Minitest::Unit::TestCase
75
75
  assert_search "product", ["Product A"], where: {color: ["RED"]}
76
76
  end
77
77
 
78
+ def test_where_nil
79
+ store [
80
+ {name: "Product A"},
81
+ {name: "Product B", color: "red"}
82
+ ]
83
+ assert_search "product", ["Product A"], where: {color: nil}
84
+ end
85
+
78
86
  def test_near
79
87
  store [
80
88
  {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-03 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tire