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: eb16f03166129357dbb2c3d61aa46e067c762ca6
4
- data.tar.gz: bad1d714a6ede119d4e2b0ec84e2517d09c7d8af
3
+ metadata.gz: 64e3bd3d865b5e88973e645777b5eb239ecba731
4
+ data.tar.gz: aacdce5cf520442a2ddb233fa7f1e32aa53cfa21
5
5
  SHA512:
6
- metadata.gz: 2ec7397589a39078db6410f3b40c11aa55b53acb78678cf5a25fe219bc901a668d530b6042c1a6a2e14702e878e2e8abcefa7e1ce3b8874cab232490f7244a77
7
- data.tar.gz: 43198f172b96b766e808a4cfb47ab3320efe368cd6eeb30c8dbde6813707c1f3751e7bbd349a0cda4ba9fdaed048a6b101ccfa17280b542a9f0e43aef6b71f2b
6
+ metadata.gz: 318149aaa04d9cb4ecd2d62452c880351029c0d4a4e5194e943e72480707295c9a993bccdb5f6522bfccb9deafc5bbe1cd4ad98438b5898b0df302c1019dd169
7
+ data.tar.gz: 89e95869db7307f10b161ee28a0b6afd582bcdc2079f34dead7054f32fb412e2019927c4de282eac8b6db7d56cdaf2fb40646af968f4d6d9b9638e31f30ed43f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CloudSesame (0.1.1)
4
+ CloudSesame (0.1.2)
5
5
  aws-sdk (~> 2)
6
6
 
7
7
  GEM
data/cloud_sesame.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'CloudSesame'
3
- s.version = '0.1.2'
3
+ s.version = '0.1.3'
4
4
  s.date = '2016-01-13'
5
5
  s.summary = "AWS CloudSearch Query Interface"
6
6
  s.description = "AWS CloudSearch Query Interface"
@@ -4,7 +4,7 @@ module CloudSesame
4
4
  class FilterQuery < Abstract
5
5
 
6
6
  def compile
7
- { filter_query: compiled } unless (compiled = root.compile).empty?
7
+ { filter_query: root.compile }
8
8
  end
9
9
 
10
10
  def root
@@ -49,7 +49,11 @@ module CloudSesame
49
49
  compiled.merge!(node.compile || {})
50
50
  end
51
51
 
52
- convert_to_structured_query(compiled) if compiled[:query].empty?
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: "structured",
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 structured' do
22
- expect(request.compile).to include(query_parser: 'structured')
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
@@ -2,57 +2,57 @@ require 'spec_helper'
2
2
 
3
3
  describe CloudSesame, focus: true do
4
4
 
5
- # # AWS initializer
6
- # require 'yaml'
7
- # YAML.load_file('aws.yml').each do |key, value|
8
- # ENV["AWS_#{ key }"] = value
9
- # end
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
- # # 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
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
- # # Usage Example
18
- # class Product
19
- # include CloudSesame
17
+ # Usage Example
18
+ class Product
19
+ include CloudSesame
20
20
 
21
- # define_cloudsearch do
21
+ define_cloudsearch do
22
22
 
23
- # # Product CloudSesame Config
24
- # config.endpoint = ENV['AWS_ENDPOINT']
25
- # config.region = ENV['AWS_REGION']
23
+ # Product CloudSesame Config
24
+ config.endpoint = ENV['AWS_ENDPOINT']
25
+ config.region = ENV['AWS_REGION']
26
26
 
27
- # default_size 100
27
+ default_size 100
28
28
 
29
- # field :searchable_text, query: { weight: 2 }
30
- # field :description, query: true
31
- # field :tags
29
+ field :searchable_text, query: { weight: 2 }
30
+ field :description, query: true
31
+ field :tags
32
32
 
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
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
- # scope :men_tag, -> { tags "men" }
42
- # scope :and_mens, -> { and! { tags "men"} }
41
+ scope :men_tag, -> { tags "men" }
42
+ scope :and_mens, -> { and! { tags "men"} }
43
43
 
44
- # end
44
+ end
45
45
 
46
- # end
46
+ end
47
47
 
48
- # result = Product.cloudsearch.query("shoes")
49
- # .page(3)
50
- # .or {
51
- # tags.not.start_with 'home', 'outdoor'
52
- # price.start_with(100)
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
- # # result.included?(price: 100)
55
+ # result.included?(price: 100)
56
56
  # binding.pry
57
57
 
58
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudSesame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chu