search_flip 4.0.0.beta5 → 4.0.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -0
- data/lib/search_flip/config.rb +7 -1
- data/lib/search_flip/json.rb +2 -13
- data/lib/search_flip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb9f652fcf2d89715a4ac400906e2b4702bae052b721f671e31caaceca01fd37
|
4
|
+
data.tar.gz: c1bca6110c7e40a223462f183021763ce3dc89f538e5d492099cee751988292d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/search_flip/config.rb
CHANGED
@@ -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
|
data/lib/search_flip/json.rb
CHANGED
@@ -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,
|
4
|
+
Oj.dump(obj, SearchFlip::Config[:json_options])
|
16
5
|
end
|
17
6
|
|
18
7
|
def self.parse(json)
|
19
|
-
Oj.load(json,
|
8
|
+
Oj.load(json, SearchFlip::Config[:json_options])
|
20
9
|
end
|
21
10
|
end
|
22
11
|
end
|
data/lib/search_flip/version.rb
CHANGED