arelastic 1.0.1 → 1.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641cd6053b327302f8529f932cdc9ebbdd1cf2db
|
4
|
+
data.tar.gz: 5efe134f612087964773827a385cd666a0772d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb4a0a08070175f28a8a0c3ac643862286a04db60bdc745525283af0966caa77331b5c74fd7e8f054c5569f754f45f846d737c3ee3ff5d16f07ecacf8118fd9
|
7
|
+
data.tar.gz: 0814f98db8b56257e05f607f64f551b3e311a6f02248f2f8e246e3004cb1bb52440b0ea992aa47a01dee280527a9e411167be9159197398ec591be2289105cfd
|
data/lib/arelastic/filters.rb
CHANGED
@@ -2,6 +2,7 @@ require 'arelastic/filters/filter'
|
|
2
2
|
|
3
3
|
require 'arelastic/filters/and'
|
4
4
|
require 'arelastic/filters/exists'
|
5
|
+
require 'arelastic/filters/geo_bounding_box'
|
5
6
|
require 'arelastic/filters/geo_distance'
|
6
7
|
require 'arelastic/filters/has_child'
|
7
8
|
require 'arelastic/filters/ids'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Arelastic
|
2
|
+
module Filters
|
3
|
+
class GeoBoundingBox < Arelastic::Filters::Filter
|
4
|
+
attr_accessor :field, :top_left, :bottom_right, :options
|
5
|
+
def initialize(field, top_left, bottom_right, options = {})
|
6
|
+
@field = field
|
7
|
+
@top_left = top_left
|
8
|
+
@bottom_right = bottom_right
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def as_elastic
|
13
|
+
params = {field => {"top_left" => top_left, "bottom_right" => bottom_right}}.update(options)
|
14
|
+
|
15
|
+
{ "geo_bounding_box" => params }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class Arelastic::Filters::GeoBoundingBoxTest < Minitest::Test
|
4
|
+
def test_as_elastic
|
5
|
+
expected = {
|
6
|
+
"geo_bounding_box" => {
|
7
|
+
"location" => {
|
8
|
+
"top_left" => [40, -70],
|
9
|
+
"bottom_right" => [30, -60]
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
assert_equal(
|
15
|
+
expected,
|
16
|
+
Arelastic::Filters::GeoBoundingBox.new('location', [40, -70], [30, -60]).as_elastic
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_as_elastic_with_options
|
21
|
+
expected = {
|
22
|
+
"geo_bounding_box" => {
|
23
|
+
"index" => true,
|
24
|
+
"location" => {
|
25
|
+
"top_left" => [40, -70],
|
26
|
+
"bottom_right" => [30, -60]
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
assert_equal(
|
32
|
+
expected,
|
33
|
+
Arelastic::Filters::GeoBoundingBox.new('location', [40, -70], [30, -60], 'index' => true).as_elastic
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arelastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Higgins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build Elastic Search queries with objects
|
14
14
|
email: developer@matthewhiggins.com
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/arelastic/filters/and.rb
|
43
43
|
- lib/arelastic/filters/exists.rb
|
44
44
|
- lib/arelastic/filters/filter.rb
|
45
|
+
- lib/arelastic/filters/geo_bounding_box.rb
|
45
46
|
- lib/arelastic/filters/geo_distance.rb
|
46
47
|
- lib/arelastic/filters/has_child.rb
|
47
48
|
- lib/arelastic/filters/ids.rb
|
@@ -114,6 +115,7 @@ files:
|
|
114
115
|
- test/arelastic/builders/sort_test.rb
|
115
116
|
- test/arelastic/filters/exists_test.rb
|
116
117
|
- test/arelastic/filters/filter_test.rb
|
118
|
+
- test/arelastic/filters/geo_bounding_box_test.rb
|
117
119
|
- test/arelastic/filters/geo_distance_test.rb
|
118
120
|
- test/arelastic/filters/has_child_test.rb
|
119
121
|
- test/arelastic/filters/ids_test.rb
|
@@ -160,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
162
|
version: 1.8.11
|
161
163
|
requirements: []
|
162
164
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.4.5
|
165
|
+
rubygems_version: 2.4.5.1
|
164
166
|
signing_key:
|
165
167
|
specification_version: 4
|
166
168
|
summary: Elastic Search query builder
|