CloudSesame 0.1.2 → 0.1.3
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: 64e3bd3d865b5e88973e645777b5eb239ecba731
|
4
|
+
data.tar.gz: aacdce5cf520442a2ddb233fa7f1e32aa53cfa21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 318149aaa04d9cb4ecd2d62452c880351029c0d4a4e5194e943e72480707295c9a993bccdb5f6522bfccb9deafc5bbe1cd4ad98438b5898b0df302c1019dd169
|
7
|
+
data.tar.gz: 89e95869db7307f10b161ee28a0b6afd582bcdc2079f34dead7054f32fb412e2019927c4de282eac8b6db7d56cdaf2fb40646af968f4d6d9b9638e31f30ed43f
|
data/Gemfile.lock
CHANGED
data/cloud_sesame.gemspec
CHANGED
@@ -49,7 +49,11 @@ module CloudSesame
|
|
49
49
|
compiled.merge!(node.compile || {})
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
if compiled[:filter_query].empty?
|
53
|
+
compiled.delete(:filter_query)
|
54
|
+
elsif compiled[:query].empty?
|
55
|
+
convert_to_structured_query(compiled)
|
56
|
+
end
|
53
57
|
|
54
58
|
compiled
|
55
59
|
end
|
@@ -12,14 +12,14 @@ module CloudSesame
|
|
12
12
|
it 'should return an default request' do
|
13
13
|
expect(request.compile).to include(
|
14
14
|
query: "",
|
15
|
-
query_parser: "
|
15
|
+
query_parser: "simple",
|
16
16
|
start: 0,
|
17
17
|
size: 10
|
18
18
|
)
|
19
19
|
expect(request.compile).to_not include(:query_options, :filter_query, :sort)
|
20
20
|
end
|
21
|
-
it 'should set query_parser to
|
22
|
-
expect(request.compile).to include(query_parser: '
|
21
|
+
it 'should set query_parser to simple' do
|
22
|
+
expect(request.compile).to include(query_parser: 'simple')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
context 'when theres query' do
|
data/spec/cloud_sesame_spec.rb
CHANGED
@@ -2,57 +2,57 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe CloudSesame, focus: true do
|
4
4
|
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
# AWS initializer
|
6
|
+
require 'yaml'
|
7
|
+
YAML.load_file('aws.yml').each do |key, value|
|
8
|
+
ENV["AWS_#{ key }"] = value
|
9
|
+
end
|
10
10
|
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
# Domain Initializer /config/initializers/cloudsearch.rb
|
12
|
+
CloudSesame::Domain::Client.configure do |config|
|
13
|
+
config.access_key = ENV['AWS_ACCESS_KEY_ID']
|
14
|
+
config.secret_key = ENV['AWS_SECRET_ACCESS_KEY']
|
15
|
+
end
|
16
16
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
17
|
+
# Usage Example
|
18
|
+
class Product
|
19
|
+
include CloudSesame
|
20
20
|
|
21
|
-
|
21
|
+
define_cloudsearch do
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
# Product CloudSesame Config
|
24
|
+
config.endpoint = ENV['AWS_ENDPOINT']
|
25
|
+
config.region = ENV['AWS_REGION']
|
26
26
|
|
27
|
-
|
27
|
+
default_size 100
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
field :searchable_text, query: { weight: 2 }
|
30
|
+
field :description, query: true
|
31
|
+
field :tags
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
field :affiliate_advertiser_ext_id, facet: { size: 50 }
|
34
|
+
field :currency, facet: true
|
35
|
+
field :discount_percentage, facet: { buckets: %w([10,100] [25,100] [50,100] [70,100]), method: 'interval' }
|
36
|
+
field :manufacturer_name, facet: { size: 50 }
|
37
|
+
field :price, facet: { buckets: %w([0,25] [25,50] [50,100] [100,200] [200,}), method: 'interval' }
|
38
|
+
field :category_string, facet: { sort: 'bucket', size: 10_000 }
|
39
|
+
field :created_at
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
scope :men_tag, -> { tags "men" }
|
42
|
+
scope :and_mens, -> { and! { tags "men"} }
|
43
43
|
|
44
|
-
|
44
|
+
end
|
45
45
|
|
46
|
-
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
result = Product.cloudsearch.query("shoes")
|
49
|
+
.page(3)
|
50
|
+
.or {
|
51
|
+
tags.not.start_with 'home', 'outdoor'
|
52
|
+
price.start_with(100)
|
53
|
+
}
|
54
54
|
|
55
|
-
#
|
55
|
+
# result.included?(price: 100)
|
56
56
|
# binding.pry
|
57
57
|
|
58
58
|
end
|