arelastic 1.1.2 → 1.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d79ffe813785f55f0bd3e040733b153097536ce7
|
4
|
+
data.tar.gz: bee96019633d9749923bd18c89e98f6534a77f99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9ec7ea6554904b71cc2b2d3df584f50650ce0c8a298df1c9bb119c126a1d739c5e581f98a07773c7412e80e7b3cc191e268c7fefb19ba186d43094abf2271fa
|
7
|
+
data.tar.gz: 55d443c8e3f3a8cc67699d8096c62a527bdab3306d3b3748aa15085ad5c9e57d708e3c6815c11a5816d6fdcbe75f2a2b3e446e1a37f2d09efd3c4a87f84bb195
|
@@ -52,6 +52,10 @@ module Arelastic
|
|
52
52
|
Arelastic::Filters::Missing.new field, options
|
53
53
|
end
|
54
54
|
|
55
|
+
def regexp other
|
56
|
+
Arelastic::Filters::Regexp.new field, other
|
57
|
+
end
|
58
|
+
|
55
59
|
def gteq other
|
56
60
|
range 'gte' => other
|
57
61
|
end
|
@@ -74,4 +78,4 @@ module Arelastic
|
|
74
78
|
end
|
75
79
|
end
|
76
80
|
end
|
77
|
-
end
|
81
|
+
end
|
data/lib/arelastic/filters.rb
CHANGED
@@ -15,6 +15,7 @@ require 'arelastic/filters/or'
|
|
15
15
|
require 'arelastic/filters/prefix'
|
16
16
|
require 'arelastic/filters/query'
|
17
17
|
require 'arelastic/filters/range'
|
18
|
+
require 'arelastic/filters/regexp'
|
18
19
|
require 'arelastic/filters/script'
|
19
20
|
require 'arelastic/filters/term'
|
20
21
|
require 'arelastic/filters/terms'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Arelastic
|
2
|
+
module Filters
|
3
|
+
#
|
4
|
+
# Implements support for the Regexp filter.
|
5
|
+
#
|
6
|
+
# Does not support Ruby `Regexp` objects, because Elasticsearch's regular
|
7
|
+
# expression syntax only supports a subset of the operators usually
|
8
|
+
# implemented in a fully-featured regex engine.
|
9
|
+
#
|
10
|
+
# Reference: https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-regexp-filter.html
|
11
|
+
#
|
12
|
+
class Regexp < Filter
|
13
|
+
binary 'regexp'
|
14
|
+
|
15
|
+
def initialize(field, value, options = {})
|
16
|
+
if value.is_a?(::Regexp)
|
17
|
+
raise TypeError.new('Regexp objects are not allowed to be Regexp filter values')
|
18
|
+
end
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -59,6 +59,11 @@ class Arelastic::Builders::FilterTest < Minitest::Test
|
|
59
59
|
assert_equal expected, builder.missing.as_elastic
|
60
60
|
end
|
61
61
|
|
62
|
+
def test_regexp
|
63
|
+
expected = {"regexp" => {"color" => "green(-blue)?"}}
|
64
|
+
assert_equal expected, builder.regexp("green(-blue)?").as_elastic
|
65
|
+
end
|
66
|
+
|
62
67
|
def test_range
|
63
68
|
expected = {"range" => {"color" => {"lt" => 5}}}
|
64
69
|
assert_equal expected, builder.lt(5).as_elastic
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class Arelastic::Filters::ExistsTest < Minitest::Test
|
4
|
+
def test_setting_value_as_regexp_object
|
5
|
+
assert_raises TypeError do
|
6
|
+
Arelastic::Filters::Regexp.new('color', /yellow(-green)?/)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_string_value
|
11
|
+
expected = { 'regexp' => { 'color' => 'blue(-green)?' } }
|
12
|
+
|
13
|
+
assert_equal expected, Arelastic::Filters::Regexp.new('color', 'blue(-green)?').as_elastic
|
14
|
+
end
|
15
|
+
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Higgins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build Elastic Search queries with objects
|
14
14
|
email: developer@matthewhiggins.com
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/arelastic/filters/prefix.rb
|
56
56
|
- lib/arelastic/filters/query.rb
|
57
57
|
- lib/arelastic/filters/range.rb
|
58
|
+
- lib/arelastic/filters/regexp.rb
|
58
59
|
- lib/arelastic/filters/script.rb
|
59
60
|
- lib/arelastic/filters/term.rb
|
60
61
|
- lib/arelastic/filters/terms.rb
|
@@ -126,6 +127,7 @@ files:
|
|
126
127
|
- test/arelastic/filters/nested_test.rb
|
127
128
|
- test/arelastic/filters/not_test.rb
|
128
129
|
- test/arelastic/filters/query_test.rb
|
130
|
+
- test/arelastic/filters/regexp_test.rb
|
129
131
|
- test/arelastic/filters/script_test.rb
|
130
132
|
- test/arelastic/mappings/types/binary_test.rb
|
131
133
|
- test/arelastic/mappings/types/multi_field_test.rb
|