elasticated 2.1.1 → 2.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: 0846f0bd2f42790835fc5ccbefe6710910ef7913
4
- data.tar.gz: 7fd87d5d529da953dffc77099a1b1499666f5d77
3
+ metadata.gz: 7387656ed02b23a0dd1926af85e5bc0f1d6e11fe
4
+ data.tar.gz: 238aa946faf6a8c8472df905e5239ce01b42dffe
5
5
  SHA512:
6
- metadata.gz: ce0fae8105a66daa06e73c9b70aa60d67708f3a329abb2caee9d6dc1b4e97f533bef1fde827cd8e43fb2334d20b2b4a9457ce4683b30a89db8732e58674b252a
7
- data.tar.gz: 81bcb959a0937e9063becadc590cf3c40ac7a0227fa501513947998054939aade2e2de75979345253976697c93defb75d9ae7cfd87207d3b8339ac562005d754
6
+ metadata.gz: 28c779821945de5bfc766e516b85e7e691c9bc41eb2a8dcb48028fd7a695add6ccc63e20b33358ce68ae3470ddca97c26bfd6cd224fb4ebdca9471d309224c89
7
+ data.tar.gz: e19fbc522bb1e6d1f4227051a8a9f72232baede359213f5fd94375a561ba8cec5e9439d66e47b5368c25e7a6092fe105ae9d2a6a6bb367b175a9f4908655a40e
@@ -59,6 +59,12 @@ module Elasticated
59
59
  self
60
60
  end
61
61
 
62
+ def sort_randomly
63
+ self._sort ||= Array.new
64
+ _sort << { _script: { script: "Math.random()", type: "number" } }
65
+ self
66
+ end
67
+
62
68
  def source(*fields_array)
63
69
  self._source = fields_array.flatten
64
70
  self
data/lib/version.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  module Elasticated
2
- VERSION = '2.1.1'
2
+ VERSION = '2.2.0'
3
3
  end
4
4
 
5
5
  # Changelog
6
6
 
7
+ # 2.2.0
8
+ # Se agrega la funcionalidad para especificar un orden aleatorio en las queries
9
+
7
10
  # 2.1.1
8
11
  # Ahora se tiene en cuenta si la query tiene o no aggregations al momento de llamar a Repository#execute_aggregated_search
9
12
 
data/spec/query_spec.rb CHANGED
@@ -94,6 +94,15 @@ module Elasticated
94
94
  expect(q.build).to eq expected_result
95
95
  end
96
96
 
97
+ it "should build a 'match_all' query sorted randomly" do
98
+ q.sort_randomly
99
+ expected_result = {
100
+ query: { match_all: {} },
101
+ sort: [ { _script: { script: "Math.random()", type: "number" } } ]
102
+ }
103
+ expect(q.build).to eq expected_result
104
+ end
105
+
97
106
  it "should build a 'match_all' query with max size" do
98
107
  q.size 5
99
108
  expected_result = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticated
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Fernandez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-21 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler