stretchy 0.6.0 → 0.7.0

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: e36573d3774c867031bf443889b538d83cd97976
4
- data.tar.gz: 90490ce53bb095a4d160b25dc4db38bca87ea92f
3
+ metadata.gz: 12bb7b9359e948fc32ff9d27f45544220ea82066
4
+ data.tar.gz: 43608164105614fbc8b5165eea18cf0fd9ddc855
5
5
  SHA512:
6
- metadata.gz: adcd1104eae7977fd773e29bfbaa1e28f56e5c79408c7c3b3d68533ed8afd7e53b9d12f8f12acbba2a33a27b8b9d97bdc32aebcb0a5ac004013fb084dfa4b51d
7
- data.tar.gz: 6bc2768805817f20749aa6eb2f8ef615cc71b1b87a8ae5b3eca4cc5d85e2f08b702a4793bd1e5f11bc7cb1bc9c450f4c60af054ac23b4e300195dd153d62e25d
6
+ metadata.gz: dc23211b16ca77b169658edebae3f3fb502b0d7f9279c6c6ff2349e989b93c58c12306c47383f3da629536d72e0de5d079b1e3673c2820187b160f1b54532a54
7
+ data.tar.gz: 0f485ba770bf7c9334fad83a62a0be88407d355da989421564c9af37b8acd14395037da2e50b286b5b3806129f0a2ea95b8bf765470cbac0b08d8da27334028b
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.3.3
data/Dockerfile CHANGED
@@ -1,5 +1,9 @@
1
- FROM ruby:2.2.0
2
- RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
1
+ FROM ruby:slim
2
+ RUN apt-get update -qq && apt-get install -y \
3
+ git \
4
+ build-essential \
5
+ libpq-dev \
6
+ curl
3
7
  RUN gem install bundler
4
8
  RUN mkdir /stretchy
5
9
  WORKDIR /stretchy
data/README.md CHANGED
@@ -219,7 +219,7 @@ Performs a query for the given string anywhere in the document. At least one of
219
219
  api = api.more_like(ids: [1, 2, 3])
220
220
  .more_like(docs: other_search.results)
221
221
  .more_like(
222
- like_text: 'puppies and kittens are great',
222
+ like: 'puppies and kittens are great',
223
223
  fields: ['about_me']
224
224
  )
225
225
  ```
@@ -436,7 +436,7 @@ Included in the Results object for Kaminari compatibility.
436
436
 
437
437
  ## Development
438
438
 
439
- After checking out the repo, run `bundle install` to install dependencies. Then, run `pry` for an interactive prompt that will allow you to experiment.
439
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `pry` for an interactive prompt that will allow you to experiment. Run specs with `rspec`
440
440
 
441
441
  ## Contributing
442
442
 
@@ -1,13 +1,24 @@
1
- elastic:
2
- image: elasticsearch:2.1
3
- web:
4
- build: .
5
- command: bundle exec rake
6
- environment:
7
- ELASTICSEARCH_URL: 'elastic:9200'
8
- volumes:
9
- - .:/stretchy
10
- ports:
11
- - "3000:3000"
12
- links:
13
- - elastic
1
+ version: '2'
2
+ services:
3
+ elastictwo:
4
+ image: elasticsearch:2-alpine
5
+ elasticfive:
6
+ image: elasticsearch:5-alpine
7
+ testtwo:
8
+ build: .
9
+ command: bundle exec rake
10
+ environment:
11
+ ELASTICSEARCH_URL: 'elastictwo:9200'
12
+ volumes:
13
+ - .:/stretchy
14
+ links:
15
+ - elastictwo
16
+ testfive:
17
+ build: .
18
+ command: bundle exec rake
19
+ environment:
20
+ ELASTICSEARCH_URL: 'elasticfive:9200'
21
+ volumes:
22
+ - .:/stretchy
23
+ links:
24
+ - elastictwo
@@ -22,7 +22,7 @@ module Stretchy
22
22
  end
23
23
 
24
24
  def node
25
- @node ||= if boost_nodes.any?
25
+ @node ||= if function_score_node?
26
26
  function_score_node
27
27
  elsif query_nodes.any?
28
28
  query_node
@@ -39,6 +39,10 @@ module Stretchy
39
39
  @boost_nodes ||= nodes.select {|n| n.context? :boost }
40
40
  end
41
41
 
42
+ def function_score_node?
43
+ boost_nodes.reject { |n| n.empty? }.any?
44
+ end
45
+
42
46
  private
43
47
 
44
48
  def query_node
@@ -76,7 +80,7 @@ module Stretchy
76
80
 
77
81
  def compile_boost_functions
78
82
  boost_nodes.map do |n|
79
- next unless n.json.any?
83
+ next if n.empty?
80
84
  n.json
81
85
  end.compact
82
86
  end
@@ -66,9 +66,11 @@ module Stretchy
66
66
  end
67
67
 
68
68
  def fields(*list)
69
- add_root fields: list
69
+ add_root _source: list
70
70
  end
71
71
 
72
+ alias :source :fields
73
+
72
74
  def aggs(params = {})
73
75
  add_body aggs: params
74
76
  end
@@ -23,9 +23,7 @@ module Stretchy
23
23
  end
24
24
 
25
25
  def extract_boost_params!(params)
26
- boost_params = Utils.extract_options!(params, BOOST_OPTIONS)
27
- boost_params = {weight: DEFAULT_WEIGHT} unless boost_params.any?
28
- boost_params
26
+ Utils.extract_options!(params, BOOST_OPTIONS)
29
27
  end
30
28
 
31
29
  def extract_function_score_options!(params)
@@ -53,12 +51,11 @@ module Stretchy
53
51
  context[:fn_score] = extract_function_score_options!(params)
54
52
  context[:boost] = true
55
53
  context[:filter] = true
56
- json = context[:query] ? {query: params} : params
57
- Node.new(boost_params.merge(filter: json), context)
54
+ boost_params.merge!(filter: params) unless Utils.is_empty? params
55
+ Node.new(boost_params, context)
58
56
  end
59
57
 
60
58
  def context_nodes(params, context = default_context)
61
- # binding.pry
62
59
  if context[:boost]
63
60
  params_to_boost(params, context)
64
61
  elsif context[:filter] && !context[:query]
@@ -75,7 +72,12 @@ module Stretchy
75
72
  nodes = context_nodes(params, subcontext)
76
73
  collector = AndCollector.new(nodes, subcontext)
77
74
 
78
- Node.new(boost_params.merge(filter: collector.json), context)
75
+ boost_params.merge!(filter: collector.json) if collector.any?
76
+ if boost_params.count == 1 && boost_params.key?(:filter)
77
+ boost_params[:weight] = DEFAULT_WEIGHT
78
+ end
79
+
80
+ Node.new(boost_params, context)
79
81
  end
80
82
 
81
83
  def params_to_queries(params, context = default_context)
@@ -103,7 +105,8 @@ module Stretchy
103
105
  when Range
104
106
  Node.new({range: {field => {gte: val.min, lte: val.max}}}, context)
105
107
  when nil
106
- Node.new({missing: {field: field}}, context)
108
+ nil_ctx = context.merge(must_not: true)
109
+ Node.new({exists: {field: field}}, nil_ctx)
107
110
  when Hash
108
111
  nested(val, field, context)
109
112
  else
@@ -9,6 +9,10 @@ module Stretchy
9
9
  @context = context
10
10
  end
11
11
 
12
+ def empty?
13
+ !@json.any?
14
+ end
15
+
12
16
  def context?(*args)
13
17
  args.all? {|c| !!context[c] }
14
18
  end
@@ -1,3 +1,3 @@
1
1
  module Stretchy
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/solano.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  ruby_version: ruby-2.2.3
3
- bundler_version: 1.9.4
3
+ bundler_version: 1.13.7
4
4
  test_pattern:
5
5
  - spec/**/*_spec.rb
6
6
  elasticsearch:
7
- version: '2.1'
7
+ version: 5.0.1
8
8
  java:
9
- java_version: java-7-openjdk
9
+ java_version: java-8-openjdk
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "elasticsearch", "~> 1.0"
22
+ spec.add_dependency "elasticsearch", "~> 5.0"
23
23
  spec.add_dependency "excon", "~> 0.45"
24
24
 
25
25
  spec.add_development_dependency "rake", "~> 10.4"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stretchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - agius
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: excon
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -175,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.4.5.1
178
+ rubygems_version: 2.5.2
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Query builder for Elasticsearch
182
182
  test_files: []
183
- has_rdoc: