tire 0.1.13 → 0.1.13.5

Sign up to get free protection for your applications and to get access to all the features.
data/examples/tire-dsl.rb CHANGED
@@ -533,6 +533,7 @@ end
533
533
  #
534
534
  # * [terms](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)
535
535
  # * [date](http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html)
536
+ # * [query](http://www.elasticsearch.org/guide/reference/api/search/facets/query-facet.html)
536
537
 
537
538
  # We have seen that _ElasticSearch_ facets enable us to fetch complex aggregations from our data.
538
539
  #
@@ -31,6 +31,10 @@ module Tire
31
31
  @value = { :range => { :field => field, :ranges => ranges }.update(options) }
32
32
  end
33
33
 
34
+ def query(&block)
35
+ @value = { :query => Query.new(&block).to_hash }
36
+ end
37
+
34
38
  def to_json
35
39
  to_hash.to_json
36
40
  end
data/lib/tire/version.rb CHANGED
@@ -1,15 +1,9 @@
1
1
  module Tire
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.13.5"
3
3
 
4
4
  CHANGELOG =<<-END
5
5
  IMPORTANT CHANGES LATELY:
6
6
 
7
- # Added `<after/before>_update_elastic_search_index` callbacks for models
8
- # Search performs GET instead of POST
9
- # Added percolator support
10
- # Added percolator support for models
11
- # CHANGELOG support in gemspec
12
- # [FIX] Do not redefine #to_hash in models
13
- # [FIX] Added that MyModel#update_elastic_search_index sets _index, _type, _version properties
7
+ # Added a "query" facet
14
8
  END
15
9
  end
@@ -1 +1 @@
1
- {"title" : "One", "tags" : ["ruby"], "published_on" : "2011-01-01"}
1
+ {"title" : "One", "tags" : ["ruby"], "published_on" : "2011-01-01", "draft" : true}
@@ -76,6 +76,63 @@ module Tire
76
76
 
77
77
  end
78
78
 
79
+ context "query facets" do
80
+
81
+ should "return aggregated values for string query" do
82
+ s = Tire.search('articles-test') do
83
+ facet 'tees' do
84
+ query { string 'T*' }
85
+ end
86
+ end
87
+
88
+ count = s.results.facets['tees']['count']
89
+ assert_equal 2, count, s.results.facets['tees'].inspect
90
+ end
91
+
92
+ should "return aggregated values for a string query" do
93
+ s = Tire.search('articles-test') do
94
+ facet 'tees' do
95
+ query { string 'T*' }
96
+ end
97
+ end
98
+
99
+ count = s.results.facets['tees']['count']
100
+ assert_equal 2, count, s.results.facets['tees'].inspect
101
+ end
102
+
103
+ should "return aggregated values for _exists_ string query" do
104
+ s = Tire.search('articles-test') do
105
+ facet 'drafts' do
106
+ query { string '_exists_:draft' }
107
+ end
108
+ end
109
+
110
+ count = s.results.facets['drafts']['count']
111
+ assert_equal 1, count, s.results.facets['drafts'].inspect
112
+ end
113
+
114
+ should "return aggregated values for a terms query" do
115
+ s = Tire.search('articles-test') do
116
+ facet 'friends' do
117
+ query { terms :tags, ['ruby', 'python'] }
118
+ end
119
+ end
120
+
121
+ count = s.results.facets['friends']['count']
122
+ assert_equal 2, count, s.results.facets['friends'].inspect
123
+
124
+ s = Tire.search('articles-test') do
125
+ facet 'friends' do
126
+ query { terms :tags, ['ruby', 'python'], :minimum_match => 2 }
127
+ end
128
+ end
129
+
130
+ count = s.results.facets['friends']['count']
131
+ assert_equal 1, count, s.results.facets['friends'].inspect
132
+ end
133
+
134
+ end
135
+
79
136
  end
80
137
 
81
138
  end
@@ -36,7 +36,7 @@ module Tire
36
36
  end
37
37
 
38
38
  assert_equal 1, s.results.count
39
- assert_equal 3, s.results.facets['tags'].size
39
+ assert_equal 3, s.results.facets['tags']['terms'].size
40
40
  end
41
41
 
42
42
  end
@@ -69,6 +69,15 @@ module Tire::Search
69
69
  end
70
70
  end
71
71
 
72
+ context "query facet" do
73
+ should "encode facet options" do
74
+ f = Facet.new('q_facet') do
75
+ query { string '_exists_:foo' }
76
+ end
77
+ assert_equal({ :q_facet => { :query => { :query_string => { :query => '_exists_:foo' } } } }.to_json, f.to_json)
78
+ end
79
+ end
80
+
72
81
  end
73
82
 
74
83
  end
metadata CHANGED
@@ -1,255 +1,196 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tire
3
- version: !ruby/object:Gem::Version
4
- hash: 1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.13.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 13
10
- version: 0.1.13
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Karel Minarik
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-06-20 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rake
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70327507052120 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 63
30
- segments:
31
- - 0
32
- - 8
33
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.8.0
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rest-client
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70327507052120
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &70327507051660 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
29
+ requirements:
43
30
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 15
46
- segments:
47
- - 1
48
- - 6
49
- - 0
31
+ - !ruby/object:Gem::Version
50
32
  version: 1.6.0
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: multi_json
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70327507051660
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &70327507051120 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
40
+ requirements:
59
41
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 1
64
- - 0
65
- version: "1.0"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
66
44
  type: :runtime
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: activemodel
70
45
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70327507051120
47
+ - !ruby/object:Gem::Dependency
48
+ name: activemodel
49
+ requirement: &70327507050620 !ruby/object:Gem::Requirement
72
50
  none: false
73
- requirements:
51
+ requirements:
74
52
  - - ~>
75
- - !ruby/object:Gem::Version
76
- hash: 7
77
- segments:
78
- - 3
79
- - 0
80
- version: "3.0"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
81
55
  type: :runtime
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
56
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70327507050620
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &70327507050160 !ruby/object:Gem::Requirement
87
61
  none: false
88
- requirements:
62
+ requirements:
89
63
  - - ~>
90
- - !ruby/object:Gem::Version
91
- hash: 23
92
- segments:
93
- - 1
94
- - 0
95
- - 0
64
+ - !ruby/object:Gem::Version
96
65
  version: 1.0.0
97
66
  type: :development
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: yajl-ruby
101
67
  prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70327507050160
69
+ - !ruby/object:Gem::Dependency
70
+ name: yajl-ruby
71
+ requirement: &70327507049660 !ruby/object:Gem::Requirement
103
72
  none: false
104
- requirements:
73
+ requirements:
105
74
  - - ~>
106
- - !ruby/object:Gem::Version
107
- hash: 63
108
- segments:
109
- - 0
110
- - 8
111
- - 0
75
+ - !ruby/object:Gem::Version
112
76
  version: 0.8.0
113
77
  type: :development
114
- version_requirements: *id006
115
- - !ruby/object:Gem::Dependency
116
- name: turn
117
78
  prerelease: false
118
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70327507049660
80
+ - !ruby/object:Gem::Dependency
81
+ name: turn
82
+ requirement: &70327507049280 !ruby/object:Gem::Requirement
119
83
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
125
- - 0
126
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
127
88
  type: :development
128
- version_requirements: *id007
129
- - !ruby/object:Gem::Dependency
130
- name: shoulda
131
89
  prerelease: false
132
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *70327507049280
91
+ - !ruby/object:Gem::Dependency
92
+ name: shoulda
93
+ requirement: &70327507048800 !ruby/object:Gem::Requirement
133
94
  none: false
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- hash: 3
138
- segments:
139
- - 0
140
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
141
99
  type: :development
142
- version_requirements: *id008
143
- - !ruby/object:Gem::Dependency
144
- name: mocha
145
100
  prerelease: false
146
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *70327507048800
102
+ - !ruby/object:Gem::Dependency
103
+ name: mocha
104
+ requirement: &70327507048380 !ruby/object:Gem::Requirement
147
105
  none: false
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- hash: 3
152
- segments:
153
- - 0
154
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
155
110
  type: :development
156
- version_requirements: *id009
157
- - !ruby/object:Gem::Dependency
158
- name: rdoc
159
111
  prerelease: false
160
- requirement: &id010 !ruby/object:Gem::Requirement
112
+ version_requirements: *70327507048380
113
+ - !ruby/object:Gem::Dependency
114
+ name: rdoc
115
+ requirement: &70327507047960 !ruby/object:Gem::Requirement
161
116
  none: false
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- hash: 3
166
- segments:
167
- - 0
168
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
169
121
  type: :development
170
- version_requirements: *id010
171
- - !ruby/object:Gem::Dependency
172
- name: sdoc
173
122
  prerelease: false
174
- requirement: &id011 !ruby/object:Gem::Requirement
123
+ version_requirements: *70327507047960
124
+ - !ruby/object:Gem::Dependency
125
+ name: sdoc
126
+ requirement: &70327507047520 !ruby/object:Gem::Requirement
175
127
  none: false
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- hash: 3
180
- segments:
181
- - 0
182
- version: "0"
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
183
132
  type: :development
184
- version_requirements: *id011
185
- - !ruby/object:Gem::Dependency
186
- name: rcov
187
133
  prerelease: false
188
- requirement: &id012 !ruby/object:Gem::Requirement
134
+ version_requirements: *70327507047520
135
+ - !ruby/object:Gem::Dependency
136
+ name: rcov
137
+ requirement: &70327507037100 !ruby/object:Gem::Requirement
189
138
  none: false
190
- requirements:
191
- - - ">="
192
- - !ruby/object:Gem::Version
193
- hash: 3
194
- segments:
195
- - 0
196
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
197
143
  type: :development
198
- version_requirements: *id012
199
- - !ruby/object:Gem::Dependency
200
- name: activerecord
201
144
  prerelease: false
202
- requirement: &id013 !ruby/object:Gem::Requirement
145
+ version_requirements: *70327507037100
146
+ - !ruby/object:Gem::Dependency
147
+ name: activerecord
148
+ requirement: &70327507036600 !ruby/object:Gem::Requirement
203
149
  none: false
204
- requirements:
150
+ requirements:
205
151
  - - ~>
206
- - !ruby/object:Gem::Version
207
- hash: 9
208
- segments:
209
- - 3
210
- - 0
211
- - 7
152
+ - !ruby/object:Gem::Version
212
153
  version: 3.0.7
213
154
  type: :development
214
- version_requirements: *id013
215
- - !ruby/object:Gem::Dependency
216
- name: supermodel
217
155
  prerelease: false
218
- requirement: &id014 !ruby/object:Gem::Requirement
156
+ version_requirements: *70327507036600
157
+ - !ruby/object:Gem::Dependency
158
+ name: supermodel
159
+ requirement: &70327507036180 !ruby/object:Gem::Requirement
219
160
  none: false
220
- requirements:
221
- - - ">="
222
- - !ruby/object:Gem::Version
223
- hash: 3
224
- segments:
225
- - 0
226
- version: "0"
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
227
165
  type: :development
228
- version_requirements: *id014
229
- - !ruby/object:Gem::Dependency
230
- name: sqlite3
231
166
  prerelease: false
232
- requirement: &id015 !ruby/object:Gem::Requirement
167
+ version_requirements: *70327507036180
168
+ - !ruby/object:Gem::Dependency
169
+ name: sqlite3
170
+ requirement: &70327507035720 !ruby/object:Gem::Requirement
233
171
  none: false
234
- requirements:
235
- - - ">="
236
- - !ruby/object:Gem::Version
237
- hash: 3
238
- segments:
239
- - 0
240
- version: "0"
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
241
176
  type: :development
242
- version_requirements: *id015
243
- description: " Tire is a Ruby client for the ElasticSearch search engine/database.\n\n It provides Ruby-like API for fluent communication with the ElasticSearch server\n and blends with ActiveModel class for convenient usage in Rails applications.\n\n It allows to delete and create indices, define mapping for them, supports\n the bulk API, and presents an easy-to-use DSL for constructing your queries.\n\n It has full ActiveRecord/ActiveModel compatibility, allowing you to index\n your models (incrementally upon saving, or in bulk), searching and\n paginating the results.\n\n Please check the documentation at <http://karmi.github.com/tire/>.\n"
177
+ prerelease: false
178
+ version_requirements: *70327507035720
179
+ description: ! " Tire is a Ruby client for the ElasticSearch search engine/database.\n\n
180
+ \ It provides Ruby-like API for fluent communication with the ElasticSearch server\n
181
+ \ and blends with ActiveModel class for convenient usage in Rails applications.\n\n
182
+ \ It allows to delete and create indices, define mapping for them, supports\n the
183
+ bulk API, and presents an easy-to-use DSL for constructing your queries.\n\n It
184
+ has full ActiveRecord/ActiveModel compatibility, allowing you to index\n your
185
+ models (incrementally upon saving, or in bulk), searching and\n paginating the
186
+ results.\n\n Please check the documentation at <http://karmi.github.com/tire/>.\n"
244
187
  email: karmi@karmi.cz
245
188
  executables: []
246
-
247
189
  extensions: []
248
-
249
- extra_rdoc_files:
190
+ extra_rdoc_files:
250
191
  - README.markdown
251
192
  - MIT-LICENSE
252
- files:
193
+ files:
253
194
  - .gitignore
254
195
  - .travis.yml
255
196
  - Gemfile
@@ -336,63 +277,35 @@ files:
336
277
  - test/unit/search_test.rb
337
278
  - test/unit/tire_test.rb
338
279
  - tire.gemspec
339
- has_rdoc: true
340
280
  homepage: http://github.com/karmi/tire
341
281
  licenses: []
342
-
343
- post_install_message: |
344
- ================================================================================
345
-
346
- Please check the documentation at <http://karmi.github.com/tire/>.
347
-
348
- --------------------------------------------------------------------------------
349
-
350
- IMPORTANT CHANGES LATELY:
351
-
352
- # Added `<after/before>_update_elastic_search_index` callbacks for models
353
- # Search performs GET instead of POST
354
- # Added percolator support
355
- # Added percolator support for models
356
- # CHANGELOG support in gemspec
357
- # [FIX] Do not redefine #to_hash in models
358
- # [FIX] Added that MyModel#update_elastic_search_index sets _index, _type, _version properties
359
-
360
- See the full changelog at <http://github.com/karmi/tire/commits/v0.1.13>.
361
-
362
- --------------------------------------------------------------------------------
363
-
364
- rdoc_options:
282
+ post_install_message: ! "================================================================================\n\n
283
+ \ Please check the documentation at <http://karmi.github.com/tire/>.\n\n--------------------------------------------------------------------------------\n\n
284
+ \ IMPORTANT CHANGES LATELY:\n\n # Added a \"query\" facet\n\n See the full changelog
285
+ at <http://github.com/karmi/tire/commits/v0.1.13.5>.\n\n--------------------------------------------------------------------------------\n"
286
+ rdoc_options:
365
287
  - --charset=UTF-8
366
- require_paths:
288
+ require_paths:
367
289
  - lib
368
- required_ruby_version: !ruby/object:Gem::Requirement
290
+ required_ruby_version: !ruby/object:Gem::Requirement
369
291
  none: false
370
- requirements:
371
- - - ">="
372
- - !ruby/object:Gem::Version
373
- hash: 3
374
- segments:
375
- - 0
376
- version: "0"
377
- required_rubygems_version: !ruby/object:Gem::Requirement
292
+ requirements:
293
+ - - ! '>='
294
+ - !ruby/object:Gem::Version
295
+ version: '0'
296
+ required_rubygems_version: !ruby/object:Gem::Requirement
378
297
  none: false
379
- requirements:
380
- - - ">="
381
- - !ruby/object:Gem::Version
382
- hash: 23
383
- segments:
384
- - 1
385
- - 3
386
- - 6
298
+ requirements:
299
+ - - ! '>='
300
+ - !ruby/object:Gem::Version
387
301
  version: 1.3.6
388
302
  requirements: []
389
-
390
303
  rubyforge_project: tire
391
- rubygems_version: 1.5.0
304
+ rubygems_version: 1.8.10
392
305
  signing_key:
393
306
  specification_version: 3
394
307
  summary: Ruby client for ElasticSearch
395
- test_files:
308
+ test_files:
396
309
  - test/fixtures/articles/1.json
397
310
  - test/fixtures/articles/2.json
398
311
  - test/fixtures/articles/3.json