search_flip 3.1.0 → 3.1.1

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
  SHA256:
3
- metadata.gz: f4e3ca349bd68555b2826d84c17b192335752947babe02ee51c5501cb04f79ca
4
- data.tar.gz: e95021068918513669da2730d613157ad7151995c4a25f532f4274c3a848710f
3
+ metadata.gz: fb8e67eac92f6f39f78dcc6770ea46d397ab7ec26b1e461b76634367a558f734
4
+ data.tar.gz: 04e8445e8039e72eac4344cb67de22c04107020b63112f01c9ed76512942c314
5
5
  SHA512:
6
- metadata.gz: dcb46f99778d2243e6fb4187f85eb9a1db9aedc25a5f2b8287c3cdb8dcd259253bc3430e1e36521ea5794a2a9188f91473ae8d8572edc8c775ac0d234ac2e284
7
- data.tar.gz: 1dbb3ba32c9c2a16f1c2b30aba7257dffc39b708f3e68ec8552c6d6d8ac6a751027a2899a3865051f7d1fdd7a6acd7a1f456eba552c7b50f4c2956292f41d413
6
+ metadata.gz: 429bacd5e7d64f922bb2c20d82d8e2ead32340f8e85abacfd55f0034791cc13c7557a5973dadf7fb19681364f56f899830aecefd7ddedab58b06c9cb8c8a13bd
7
+ data.tar.gz: f60dfa7d6396971dadd0d960442074a1702493e8149ba885fb84a09f77031b4450603a9ece5391e55d5e747a917b95a4708a0bad3232610c4d4a75ddebc88cd0
@@ -1,5 +1,12 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
+ TargetRubyVersion: 2.4
4
+
5
+ Gemspec/RequiredRubyVersion:
6
+ Enabled: false
7
+
8
+ Style/ExplicitBlockArgument:
9
+ Enabled: false
3
10
 
4
11
  Style/HashTransformValues:
5
12
  Enabled: false
@@ -5,7 +5,7 @@ env:
5
5
  - ES_IMAGE=elasticsearch:5.4
6
6
  - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:6.7.0
7
7
  - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:7.0.0
8
- - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:7.6.0
8
+ - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:7.8.0
9
9
  rvm:
10
10
  - ruby-2.5.3
11
11
  - ruby-2.6.2
@@ -1,6 +1,10 @@
1
1
 
2
2
  # CHANGELOG
3
3
 
4
+ ## v3.1.1
5
+
6
+ * Make `SearchFlip::Result.from_hit` work with the `_source` being disabled
7
+
4
8
  ## v3.1.0
5
9
 
6
10
  * Added plugin support in `SearchFlip::HTTPClient`
data/README.md CHANGED
@@ -949,6 +949,10 @@ It uses `after_commit` (if applicable, `after_save`, `after_destroy` and
949
949
  `after_touch` otherwise) hooks to synchronously update the index when your
950
950
  model changes.
951
951
 
952
+ ## Semantic Versioning
953
+
954
+ SearchFlip is using Semantic Versioning: [SemVer](http://semver.org/)
955
+
952
956
  ## Links
953
957
 
954
958
  * Elasticsearch: [https://www.elastic.co/](https://www.elastic.co/)
@@ -980,5 +984,4 @@ $ rspec
980
984
 
981
985
  That's it.
982
986
 
983
-
984
987
  [Bulk API]: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
@@ -39,6 +39,8 @@ module SearchFlip
39
39
  attr_reader :code, :body
40
40
 
41
41
  def initialize(code:, body:)
42
+ super
43
+
42
44
  @code = code
43
45
  @body = body
44
46
  end
@@ -40,7 +40,7 @@ module SearchFlip
40
40
  else
41
41
  filters = (filter_values || []) + (must_not_values || []).map { |must_not_value| { not: must_not_value } }
42
42
  queries = must_values ? { must: must_values } : {}
43
- filters_and_queries = filters + (queries.size > 0 ? [bool: queries] : [])
43
+ filters_and_queries = filters + (queries.size > 0 ? [{ bool: queries }] : [])
44
44
 
45
45
  res[:filter] = filters_and_queries.size > 1 ? { and: filters_and_queries } : filters_and_queries.first
46
46
  end
@@ -101,7 +101,7 @@ module SearchFlip
101
101
  end
102
102
 
103
103
  def respond_to_missing?(name, *args)
104
- target.respond_to?(name, *args)
104
+ target.respond_to?(name, *args) || super
105
105
  end
106
106
 
107
107
  def method_missing(name, *args, &block)
@@ -576,7 +576,7 @@ module SearchFlip
576
576
  end
577
577
 
578
578
  def respond_to_missing?(name, *args)
579
- target.respond_to?(name, *args)
579
+ target.respond_to?(name, *args) || super
580
580
  end
581
581
 
582
582
  def method_missing(name, *args, &block)
@@ -34,9 +34,10 @@ module SearchFlip
34
34
  criteria.highlight_values = (criteria.highlight_values || {}).merge(options)
35
35
 
36
36
  hash =
37
- if fields.is_a?(Hash)
37
+ case fields
38
+ when Hash
38
39
  fields
39
- elsif fields.is_a?(Array)
40
+ when Array
40
41
  fields.each_with_object({}) { |field, h| h[field] = {} }
41
42
  else
42
43
  { fields => {} }
@@ -17,7 +17,7 @@ module SearchFlip
17
17
  # SearchFlip::Result.from_hit(top_sales_hits.first)
18
18
 
19
19
  def self.from_hit(hit)
20
- raw_result = hit["_source"].dup
20
+ raw_result = (hit["_source"] || {}).dup
21
21
 
22
22
  raw_result["_hit"] = hit.each_with_object({}) do |(key, value), hash|
23
23
  hash[key] = value if key != "_source"
@@ -1,3 +1,3 @@
1
1
  module SearchFlip
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  end
@@ -36,10 +36,10 @@ RSpec.describe SearchFlip::Connection do
36
36
  it "changes the aliases" do
37
37
  connection = SearchFlip::Connection.new
38
38
 
39
- connection.update_aliases(actions: [add: { index: "products", alias: "alias1" }])
39
+ connection.update_aliases(actions: [{ add: { index: "products", alias: "alias1" } }])
40
40
  expect(connection.get_aliases(alias_name: "alias1").keys).to eq(["products"])
41
41
 
42
- connection.update_aliases(actions: [remove: { index: "products", alias: "alias1" }])
42
+ connection.update_aliases(actions: [{ remove: { index: "products", alias: "alias1" } }])
43
43
  expect(connection.alias_exists?("alias1")).to eq(false)
44
44
  end
45
45
  end
@@ -79,11 +79,11 @@ RSpec.describe SearchFlip::Connection do
79
79
 
80
80
  expect(connection.alias_exists?(:some_alias)).to eq(false)
81
81
 
82
- connection.update_aliases(actions: [add: { index: "products", alias: "some_alias" }])
82
+ connection.update_aliases(actions: [{ add: { index: "products", alias: "some_alias" } }])
83
83
 
84
84
  expect(connection.alias_exists?(:some_alias)).to eq(true)
85
85
  ensure
86
- connection.update_aliases(actions: [remove: { index: "products", alias: "some_alias" }])
86
+ connection.update_aliases(actions: [{ remove: { index: "products", alias: "some_alias" } }])
87
87
  end
88
88
  end
89
89
  end
@@ -13,5 +13,11 @@ RSpec.describe SearchFlip::Result do
13
13
 
14
14
  expect(result.key1[0].key2).to eq("value")
15
15
  end
16
+
17
+ it "works with the _source being disabled" do
18
+ result = SearchFlip::Result.from_hit("_id" => 1)
19
+
20
+ expect(result._hit._id).to eq(1)
21
+ end
16
22
  end
17
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord