search_flip 4.0.0.beta5 → 4.0.0.beta6

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: 938e1745f8cfe0173c76f26a4f15ab7e62781fd627dcccb2c2523db7f8ca51bf
4
- data.tar.gz: 2a8980bc0de4db9cb081c5186ed94bbee489a470ea30992a9e8a9c248563d3e6
3
+ metadata.gz: cb9f652fcf2d89715a4ac400906e2b4702bae052b721f671e31caaceca01fd37
4
+ data.tar.gz: c1bca6110c7e40a223462f183021763ce3dc89f538e5d492099cee751988292d
5
5
  SHA512:
6
- metadata.gz: 2d622f6d843b9975a66af4ee3d937f1eb60b255d6c5017479dae583543d8f4dbba9608209513da94ba95a3aa3323714a0c1a9b21e594f1f4a2be61844864da3c
7
- data.tar.gz: b7835e3adfd35074111e481e3ba54272e59a764a5478c569bc516aa4a8455c939618347a194802a9d6030a91bc52430bf7fac72b00c3ebca1eb09cb13021f21a
6
+ metadata.gz: 79c607032410d675a0663b13a6af21a64501a587ec1c07852e92e459b4034043121187016aabdab3672e0013fd1b86731b2c3f3a0d4484f08d39134328e3adc3
7
+ data.tar.gz: a06b1866d3322185692cab6ddd2c8a9dd88bb7eb46b955a732bf6e70fae174dbbd4f658b51cddc051c8d512f5f48619147bd32620fa24623393338360d9ed4e6
data/README.md CHANGED
@@ -882,6 +882,48 @@ Thus, if your ORM supports `.find_each`, `#id` and `#where` you are already
882
882
  good to go. Otherwise, simply add your custom implementation of those methods
883
883
  that work with whatever ORM you use.
884
884
 
885
+ ## JSON
886
+
887
+ SearchFlip is using the [Oj gem](https://github.com/ohler55/oj) to generate
888
+ and parse JSON. More concretely, SearchFlip is using:
889
+
890
+ ```ruby
891
+ Oj.dump({ key: "value" }, mode: :custom, use_to_json: true, time_format: :xmlschema, bigdecimal_as_decimal: false)
892
+ Oj.load('{"key":"value"}', mode: :custom, use_to_json: true, time_format: :xmlschema, bigdecimal_as_decimal: false)
893
+ ```
894
+
895
+ The `use_to_json` option is used for maximum compatibility, most importantly
896
+ when using rails `ActiveSupport::TimeWithZone` timestamps, which `oj` can not
897
+ serialize natively. However, `use_to_json` adds performance overhead. You can
898
+ change the json options via:
899
+
900
+ ```ruby
901
+ SearchFlip::Config[:json_options] = {
902
+ mode: :custom,
903
+ use_to_json: false,
904
+ time_format: :xmlschema,
905
+ bigdecimal_as_decimal: false
906
+ }
907
+ ```
908
+
909
+ However, you then have to convert timestamps manually for indexation via e.g.:
910
+
911
+ ```ruby
912
+ class MyIndex
913
+ # ...
914
+
915
+ def self.serialize(model)
916
+ {
917
+ # ...
918
+
919
+ created_at: model.created_at.to_time
920
+ }
921
+ end
922
+ end
923
+ ```
924
+
925
+ Please check out the oj docs for more details.
926
+
885
927
  ## Feature Support
886
928
 
887
929
  * for Elasticsearch 2.x, the delete-by-query plugin is required to delete
@@ -5,6 +5,12 @@ module SearchFlip
5
5
  bulk_limit: 1_000,
6
6
  bulk_max_mb: 100,
7
7
  auto_refresh: false,
8
- instrumenter: NullInstrumenter.new
8
+ instrumenter: NullInstrumenter.new,
9
+ json_options: {
10
+ mode: :custom,
11
+ use_to_json: true,
12
+ time_format: :xmlschema,
13
+ bigdecimal_as_decimal: false
14
+ }
9
15
  }
10
16
  end
@@ -1,22 +1,11 @@
1
1
  module SearchFlip
2
2
  class JSON
3
- @default_options = {
4
- mode: :custom,
5
- use_to_json: true,
6
- time_format: :xmlschema,
7
- bigdecimal_as_decimal: false
8
- }
9
-
10
- def self.default_options
11
- @default_options
12
- end
13
-
14
3
  def self.generate(obj)
15
- Oj.dump(obj, default_options)
4
+ Oj.dump(obj, SearchFlip::Config[:json_options])
16
5
  end
17
6
 
18
7
  def self.parse(json)
19
- Oj.load(json, default_options)
8
+ Oj.load(json, SearchFlip::Config[:json_options])
20
9
  end
21
10
  end
22
11
  end
@@ -1,3 +1,3 @@
1
1
  module SearchFlip
2
- VERSION = "4.0.0.beta5"
2
+ VERSION = "4.0.0.beta6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta5
4
+ version: 4.0.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter