flex 0.4.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +46 -7
  3. data/VERSION +1 -1
  4. data/flex.gemspec +13 -19
  5. data/lib/flex.rb +66 -392
  6. data/lib/flex/api_stubs.rb +1268 -0
  7. data/lib/flex/api_templates/cluster_api.yml +94 -0
  8. data/lib/flex/api_templates/core_api.yml +202 -0
  9. data/lib/flex/api_templates/indices_api.yml +304 -0
  10. data/lib/flex/class_proxy/base.rb +20 -6
  11. data/lib/flex/class_proxy/templates.rb +97 -0
  12. data/lib/flex/class_proxy/templates/doc.rb +91 -0
  13. data/lib/flex/class_proxy/templates/search.rb +72 -0
  14. data/lib/flex/configuration.rb +17 -49
  15. data/lib/flex/deprecation.rb +153 -0
  16. data/lib/flex/errors.rb +2 -1
  17. data/lib/flex/http_clients/base.rb +15 -0
  18. data/lib/flex/http_clients/loader.rb +51 -0
  19. data/lib/flex/http_clients/patron.rb +9 -7
  20. data/lib/flex/http_clients/rest_client.rb +6 -8
  21. data/lib/flex/logger.rb +24 -3
  22. data/lib/flex/prog_bar.rb +11 -6
  23. data/lib/flex/rails.rb +1 -13
  24. data/lib/flex/result.rb +8 -2
  25. data/lib/flex/result/document.rb +42 -13
  26. data/lib/flex/result/multi_get.rb +24 -0
  27. data/lib/flex/result/search.rb +1 -24
  28. data/lib/flex/struct/array.rb +25 -0
  29. data/lib/flex/struct/hash.rb +105 -0
  30. data/lib/flex/{result/collection.rb → struct/paginable.rb} +16 -9
  31. data/lib/flex/struct/prunable.rb +60 -0
  32. data/lib/flex/struct/symbolize.rb +27 -0
  33. data/lib/flex/tasks.rb +26 -86
  34. data/lib/flex/template.rb +60 -120
  35. data/lib/flex/template/common.rb +42 -0
  36. data/lib/flex/template/logger.rb +66 -0
  37. data/lib/flex/template/partial.rb +12 -15
  38. data/lib/flex/template/search.rb +6 -6
  39. data/lib/flex/template/slim_search.rb +1 -1
  40. data/lib/flex/template/tags.rb +19 -9
  41. data/lib/flex/templates.rb +20 -0
  42. data/lib/flex/utility_methods.rb +80 -89
  43. data/lib/flex/utils.rb +68 -25
  44. data/lib/flex/variables.rb +55 -4
  45. data/lib/tasks.rake +28 -0
  46. metadata +61 -85
  47. data/bin/flexes +0 -174
  48. data/lib/flex/api_methods.yml +0 -108
  49. data/lib/flex/class_proxy/loader.rb +0 -102
  50. data/lib/flex/class_proxy/model.rb +0 -45
  51. data/lib/flex/class_proxy/model_sync.rb +0 -23
  52. data/lib/flex/class_proxy/related_model.rb +0 -23
  53. data/lib/flex/instance_proxy/base.rb +0 -29
  54. data/lib/flex/instance_proxy/model.rb +0 -102
  55. data/lib/flex/instance_proxy/related_model.rb +0 -7
  56. data/lib/flex/loader.rb +0 -18
  57. data/lib/flex/manager.rb +0 -61
  58. data/lib/flex/model.rb +0 -24
  59. data/lib/flex/rails/engine.rb +0 -23
  60. data/lib/flex/rails/helper.rb +0 -16
  61. data/lib/flex/related_model.rb +0 -16
  62. data/lib/flex/result/indifferent_access.rb +0 -11
  63. data/lib/flex/result/source_document.rb +0 -63
  64. data/lib/flex/result/source_search.rb +0 -32
  65. data/lib/flex/structure/indifferent_access.rb +0 -44
  66. data/lib/flex/structure/mergeable.rb +0 -21
  67. data/lib/flex/template/base.rb +0 -41
  68. data/lib/flex/template/info.rb +0 -68
  69. data/lib/generators/flex/setup/setup_generator.rb +0 -48
  70. data/lib/generators/flex/setup/templates/flex_config.yml +0 -16
  71. data/lib/generators/flex/setup/templates/flex_dir/es.rb.erb +0 -18
  72. data/lib/generators/flex/setup/templates/flex_dir/es.yml.erb +0 -19
  73. data/lib/generators/flex/setup/templates/flex_dir/es_extender.rb.erb +0 -17
  74. data/lib/generators/flex/setup/templates/flex_initializer.rb.erb +0 -44
  75. data/lib/tasks/index.rake +0 -17
  76. data/test/flex.irt +0 -143
  77. data/test/flex/configuration.irt +0 -53
  78. data/test/irt_helper.rb +0 -12
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 by Domizio Demichelis
1
+ Copyright (c) 2012-2013 by Domizio Demichelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,12 +1,51 @@
1
1
  # Flex
2
2
 
3
- Flex is a complete ruby client for [ElasticSearch](http://www.elasticsearch.org). It introduces a new way to send any kind of request (not just search queries) to the ES server, and to manage any kind of response. You can transparently integrate it with **ActiveRecord** and **Mongoid** models with or without automatic synchronization, with or without **Rails**. It is fast and efficient, easy to use and customize.
3
+ Flex is the ultimate ruby client for [elasticsearch](http://elasticsearch.org). It is powerful, fast and efficient, easy to use and customize.
4
4
 
5
- ## Useful Links
5
+ It covers ALL the elasticsearch API, and transparently integrates it with your app and its components, like `Rails`, `ActiveRecord`, `Mongoid`, `ActiveModel`, `will_paginate`, `kaminari`, `elasticsearch-mapper-attachments`, ...
6
6
 
7
- * [Documentation](./flex/wiki)
8
- * [Issues](./flex/issues)
9
- * [Pull Requests](./flex/pulls)
7
+ It also implements and integrates very advanced features like chainable scopes, live-reindex, cross-model syncing, query fragment reuse, parent/child relationships, templating, self-documenting tools, detailed debugging, ...
8
+
9
+ ## Quick Start
10
+
11
+ The Flex documentation is very complete and detailed, so starting from the right topic for you will save you time. Please, pick the starting point that better describes you below:
12
+
13
+ ### For Tire Users
14
+
15
+ 1. You may be interested to start from [Why you should use Flex rather than Tire](http://ddnexus.github.io/flex/doc/7-Tutorials/1-Flex-vs-Tire.html) that is a direct comparison between the two projects.
16
+
17
+ 2. Depending on your elasticsearch knowledge you can read below the "Elasticsearch Beginner" or the "Elasticsearch Expert" starting point sections.
18
+
19
+ ### For Flex 0.x Users
20
+
21
+ 1. If you used an old flex version, please start with [How to migrate from flex 0.x](http://ddnexus.github.io/flex/doc/7-Tutorials/2-Migrate-from-0.x.html).
22
+
23
+ 2. Depending on your elasticsearch knowledge you can read below the "Elasticsearch Beginner" or the "Elasticsearch Expert" sections.
24
+
25
+ ### For Elasticsearch Beginners
26
+
27
+ 1. You may want to start with the [Index and Search External Data](http://ddnexus.github.io/flex/doc/7-Tutorials/4-Index-and-Search-External-Data.md) tutorial, since it practically doesn't require any elasticsearch knowledge. It will show you how to build your own search application with just a few lines of code. You will crawl a site, extract its content and build a simple user interface to search it with elasticsearch.
28
+
29
+ 2. Then you may want to read the [Usage Overview](http://ddnexus.github.io/flex/doc/1-Flex-Project/2-Usage-Overview.html) page. Follow the links from there in order to dig into the topics that interest you the most.
30
+
31
+ 3. You will probably like the [flex-scopes](http://ddnexus.github.io/flex/doc/3-flex-scopes) that allows you to easy search, chain toghether and reuse searching scopes in pure ruby.
32
+
33
+ ### For Elasticsearch Experts
34
+
35
+ 1. Flex provides the full elasticsearch APIs as ready to methods. Just take a look at the [API Metods](http://ddnexus.github.io/flex/doc/2-flex/2-API-Methods.html) page to appreciate its completeness.
36
+
37
+ 2. Then you may want to read the [Usage Overview](http://ddnexus.github.io/flex/doc/1-Flex-Project/2-Usage-Overview.html) page. Follow the links from there in order to dig into the topics that interest you.
38
+
39
+ 3. If you are used to create complex searching logic, you will certainly appreciate the [Templating System](http://ddnexus.github.io/flex/doc/2-flex/3-Templating) that gives you real power with great simplicity.
40
+
41
+ 4. As an elasticsearch expert, you will certainly appreciate the [Live-Reindex](http://ddnexus.github.io/flex/doc/6-flex-admin/2-Live-Reindex.html) feature: it encapsulates the solution to a quite complex problem in just one method call.
42
+
43
+ ## Links
44
+
45
+ * [Flex Project (Global Documentation)](http://ddnexus.github.io/flex/doc/)
46
+ * [flex Gem (Specific Documentation)](http://ddnexus.github.io/flex/doc/2-flex)
47
+ * [Issues](https://github.com/ddnexus/flex/issues)
48
+ * [Pull Requests](https://github.com/ddnexus/flex/pulls)
10
49
 
11
50
  ## Branches
12
51
 
@@ -18,5 +57,5 @@ Special thanks for their sponsorship to [Escalate Media](http://www.escalatemedi
18
57
 
19
58
  ## Copyright
20
59
 
21
- Copyright (c) 2012 by [Domizio Demichelis](mailto://dd.nexus@gmail.com)<br>
22
- See [LICENSE](./flex/blob/master/LICENSE) for details.
60
+ Copyright (c) 2012-2013 by [Domizio Demichelis](mailto://dd.nexus@gmail.com)<br>
61
+ See [LICENSE](https://github.com/ddnexus/flex/blob/master/LICENSE) for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 1.0.1
@@ -2,20 +2,23 @@ require 'date'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'flex'
5
- s.summary = 'Ruby Client for ElasticSearch'
5
+ s.summary = 'The ultimate ruby client for elasticsearch'
6
6
  s.description = <<-desc
7
- Flex is an innovative ruby client for ElasticSearch. With Flex your code will be clean, easy to write and read, and very short: "poetic-short". Flex is fast and efficient, easy to use and customize, and offers ActiveRecord, Mongoid and Rails integration.
7
+ Flex is the ultimate ruby client for elasticsearch. It is powerful, fast and efficient, easy to use and customize.
8
+
9
+ It covers ALL the elasticsearch API, and transparently integrates it with your app and its components, like Rails, ActiveRecord, Mongoid, ActiveModel, will_paginate, kaminari, elasticsearch-mapper-attachments, ...
10
+
11
+ It also implements and integrates very advanced features like chainable scopes, live-reindex, cross-model syncing, query fragment reuse, parent/child relationships, templating, self-documenting tools, detailed debugging, ...
8
12
  desc
9
13
  s.homepage = 'http://github.com/ddnexus/flex'
10
- s.authors = ["Domizio Demichelis"]
14
+ s.authors = ['Domizio Demichelis']
11
15
  s.email = 'dd.nexus@gmail.com'
12
- s.executables = ['flexes']
13
16
  s.extra_rdoc_files = %w[README.md]
14
17
  s.require_paths = %w[lib]
15
18
  s.files = `git ls-files -z`.split("\0")
16
19
  s.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
17
20
  s.date = Date.today.to_s
18
- s.required_rubygems_version = ">= 1.3.6"
21
+ s.required_rubygems_version = '>= 1.3.6'
19
22
  s.rdoc_options = %w[--charset=UTF-8]
20
23
  s.post_install_message = <<EOM
21
24
  ________________________________________________________________________________
@@ -23,22 +26,13 @@ ________________________________________________________________________________
23
26
  FLEX INSTALLATION NOTES
24
27
  ________________________________________________________________________________
25
28
 
26
- In order to use Flex, a supported http-client must be installed on this system.
27
-
28
- The suported http-client gems are "patron" and "rest-client".
29
-
30
- You should install "patron" (a libcurl based gem developed in C) for best
31
- performances, or install "rest-client" if you cannot use libcurl on your system.
29
+ New Documentation: http://ddnexus.github.io/flex
32
30
 
33
- As an alternative you could eventually develop your own http-client interface
34
- and set the Flex::Configuration.http_client option.
31
+ Upgrading Tutorial: http://ddnexus.github.io/flex/doc/7-Tutorials/2-Migrate-from-0.x.html
35
32
 
36
33
  ________________________________________________________________________________
37
34
  EOM
38
- s.add_runtime_dependency 'multi_json', '~> 1.3.4'
39
- s.add_runtime_dependency 'progressbar', '~> 0.11.0'
40
- s.add_runtime_dependency 'prompter', '~> 0.1.5'
41
- s.add_development_dependency 'irt', '~> 1.2.10'
42
- s.add_development_dependency 'patron', '~> 0.4.18'
43
- s.add_development_dependency 'rest-client', '~> 1.6.7'
35
+ s.add_runtime_dependency 'multi_json', '>= 1.3.4'
36
+ s.add_runtime_dependency 'progressbar', '>= 0.11.0', '~> 0.12.0'
37
+ s.add_runtime_dependency 'dye', '~> 0.1.4'
44
38
  end
@@ -1,3 +1,4 @@
1
+ require 'dye'
1
2
  require 'yaml'
2
3
  require 'ostruct'
3
4
  require 'erb'
@@ -6,429 +7,102 @@ require 'flex/logger'
6
7
  require 'flex/errors'
7
8
  require 'flex/utils'
8
9
 
9
- require 'flex/structure/indifferent_access'
10
- require 'flex/structure/mergeable'
10
+ require 'flex/struct/prunable'
11
+ require 'flex/struct/symbolize'
12
+ require 'flex/struct/hash'
13
+ require 'flex/struct/array'
14
+
15
+ require 'flex/variables'
11
16
 
12
17
  require 'flex/result'
13
- require 'flex/result/collection'
18
+ require 'flex/struct/paginable'
14
19
  require 'flex/result/document'
15
- require 'flex/result/source_document'
16
20
  require 'flex/result/search'
17
- require 'flex/result/source_search'
21
+ require 'flex/result/multi_get'
18
22
  require 'flex/result/bulk'
19
23
 
20
- require 'flex/variables'
21
-
22
- require 'flex/template/base'
24
+ require 'flex/template/common'
23
25
  require 'flex/template/partial'
26
+ require 'flex/template/logger'
24
27
  require 'flex/template'
25
28
  require 'flex/template/search'
26
29
  require 'flex/template/slim_search'
27
30
  require 'flex/template/tags'
28
- require 'flex/template/info'
29
-
30
- require 'flex/manager'
31
31
 
32
32
  require 'flex/class_proxy/base'
33
- require 'flex/class_proxy/loader'
34
- require 'flex/class_proxy/model_sync'
35
- require 'flex/class_proxy/model'
36
- require 'flex/class_proxy/related_model'
33
+ require 'flex/class_proxy/templates/search'
34
+ require 'flex/class_proxy/templates/doc'
37
35
 
38
- require 'flex/instance_proxy/base'
39
- require 'flex/instance_proxy/model'
40
- require 'flex/instance_proxy/related_model'
36
+ require 'flex/class_proxy/templates'
41
37
 
42
- require 'flex/loader'
43
- require 'flex/related_model'
44
- require 'flex/model'
38
+ require 'flex/templates'
45
39
 
46
- require 'flex/http_clients/patron'
47
- require 'flex/http_clients/rest_client'
40
+ require 'flex/http_clients/base'
41
+ require 'flex/http_clients/loader'
48
42
  require 'flex/configuration'
49
43
  require 'flex/utility_methods'
50
44
 
51
45
  require 'progressbar'
52
46
  require 'flex/prog_bar'
47
+ require 'flex/deprecation'
53
48
 
54
- module Flex
55
-
56
- VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
57
- LIB_PATH = __FILE__.sub(/flex.rb$/, '')
58
-
59
-
60
- # The following lines are autogenerated by Flex.info
61
-
62
- # ########## Flex.indices_exists ##########
63
- #
64
- # Flex::Template:
65
- # ---
66
- # indices_exists:
67
- # - HEAD
68
- # - /<<index>>
69
- #
70
- # Usage:
71
- # Flex.indices_exists :index => "flex_test_index"
72
- #
73
- def Flex.indices_exists(vars={})
74
- # this is a stub, used for reference
75
- end
76
-
77
-
78
- # ########## Flex.exist? ##########
79
- #
80
- # Flex::Template:
81
- # ---
82
- # exist?:
83
- # - HEAD
84
- # - /<<index>>
85
- #
86
- # Usage:
87
- # Flex.exist? :index => "flex_test_index"
88
- #
89
- def Flex.exist?(vars={})
90
- # this is a stub, used for reference
91
- end
92
-
93
-
94
- # ########## Flex.create_index ##########
95
- #
96
- # Flex::Template:
97
- # ---
98
- # create_index:
99
- # - PUT
100
- # - /<<index>>
101
- # - settings:
102
- # number_of_shards: <<number_of_shards= 5 >>
103
- # number_of_replicas: <<number_of_replicas= 1 >>
104
- #
105
- # Usage:
106
- # Flex.create_index :index => "flex_test_index",
107
- # :number_of_shards => 5,
108
- # :number_of_replicas => 1
109
- #
110
- def Flex.create_index(vars={})
111
- # this is a stub, used for reference
112
- end
113
-
114
-
115
- # ########## Flex.put_index ##########
116
- #
117
- # Flex::Template:
118
- # ---
119
- # put_index:
120
- # - PUT
121
- # - /<<index>>
122
- # - settings:
123
- # number_of_shards: <<number_of_shards= 5 >>
124
- # number_of_replicas: <<number_of_replicas= 1 >>
125
- #
126
- # Usage:
127
- # Flex.put_index :index => "flex_test_index",
128
- # :number_of_shards => 5,
129
- # :number_of_replicas => 1
130
- #
131
- def Flex.put_index(vars={})
132
- # this is a stub, used for reference
133
- end
134
-
135
-
136
- # ########## Flex.post_index ##########
137
- #
138
- # Flex::Template:
139
- # ---
140
- # post_index:
141
- # - POST
142
- # - /<<index>>
143
- # - settings:
144
- # number_of_shards: <<number_of_shards= 5 >>
145
- # number_of_replicas: <<number_of_replicas= 1 >>
146
- #
147
- # Usage:
148
- # Flex.post_index :index => "flex_test_index",
149
- # :number_of_shards => 5,
150
- # :number_of_replicas => 1
151
- #
152
- def Flex.post_index(vars={})
153
- # this is a stub, used for reference
154
- end
155
-
156
-
157
- # ########## Flex.get_settings ##########
158
- #
159
- # Flex::Template:
160
- # ---
161
- # get_settings:
162
- # - GET
163
- # - /<<index>>/_settings
164
- #
165
- # Usage:
166
- # Flex.get_settings :index => "flex_test_index"
167
- #
168
- def Flex.get_settings(vars={})
169
- # this is a stub, used for reference
170
- end
171
-
172
-
173
- # ########## Flex.put_mapping ##########
174
- #
175
- # Flex::Template:
176
- # ---
177
- # put_mapping:
178
- # - PUT
179
- # - /<<index>>/<<type>>/_mapping
180
- # - <<type>>:
181
- # properties: <<properties>>
182
- #
183
- # Usage:
184
- # Flex.put_mapping :properties => properties, # required
185
- # :type => nil,
186
- # :index => "flex_test_index"
187
- #
188
- def Flex.put_mapping(vars={})
189
- # this is a stub, used for reference
190
- end
191
-
192
-
193
- # ########## Flex.get_mapping ##########
194
- #
195
- # Flex::Template:
196
- # ---
197
- # get_mapping:
198
- # - GET
199
- # - /<<index>>/<<type>>/_mapping
200
- #
201
- # Usage:
202
- # Flex.get_mapping :index => "flex_test_index",
203
- # :type => nil
204
- #
205
- def Flex.get_mapping(vars={})
206
- # this is a stub, used for reference
207
- end
208
-
209
-
210
- # ########## Flex.delete_mapping ##########
211
- #
212
- # Flex::Template:
213
- # ---
214
- # delete_mapping:
215
- # - DELETE
216
- # - /<<index>>/<<type>>
217
- #
218
- # Usage:
219
- # Flex.delete_mapping :index => "flex_test_index",
220
- # :type => nil
221
- #
222
- def Flex.delete_mapping(vars={})
223
- # this is a stub, used for reference
224
- end
225
-
226
-
227
- # ########## Flex.delete_index ##########
228
- #
229
- # Flex::Template:
230
- # ---
231
- # delete_index:
232
- # - DELETE
233
- # - /<<index>>
234
- #
235
- # Usage:
236
- # Flex.delete_index :index => "flex_test_index"
237
- #
238
- def Flex.delete_index(vars={})
239
- # this is a stub, used for reference
240
- end
241
-
242
-
243
- # ########## Flex.delete_by_query ##########
244
- #
245
- # Flex::Template:
246
- # ---
247
- # delete_by_query:
248
- # - DELETE
249
- # - /<<index>>/<<type>>/_query
250
- #
251
- # Usage:
252
- # Flex.delete_by_query :index => "flex_test_index",
253
- # :type => nil
254
- #
255
- def Flex.delete_by_query(vars={})
256
- # this is a stub, used for reference
257
- end
258
-
259
-
260
- # ########## Flex.bulk ##########
261
- #
262
- # Flex::Template:
263
- # ---
264
- # bulk:
265
- # - POST
266
- # - /_bulk
267
- # - << lines >>
268
- #
269
- # Usage:
270
- # Flex.bulk :lines => lines # required
271
- #
272
- def Flex.bulk(vars={})
273
- # this is a stub, used for reference
274
- end
275
-
276
-
277
- # ########## Flex.count ##########
278
- #
279
- # Flex::Template:
280
- # ---
281
- # count:
282
- # - GET
283
- # - /<<index>>/<<type>>/_count
284
- #
285
- # Usage:
286
- # Flex.count :index => "flex_test_index",
287
- # :type => nil
288
- #
289
- def Flex.count(vars={})
290
- # this is a stub, used for reference
291
- end
292
-
293
-
294
- # ########## Flex.stats ##########
295
- #
296
- # Flex::Template:
297
- # ---
298
- # stats:
299
- # - GET
300
- # - /<<index>>/_stats/<<end_point= ~ >>
301
- #
302
- # Usage:
303
- # Flex.stats :index => "flex_test_index",
304
- # :end_point => nil
305
- #
306
- def Flex.stats(vars={})
307
- # this is a stub, used for reference
308
- end
309
-
310
-
311
- # ########## Flex.store ##########
312
- #
313
- # Flex::Template:
314
- # ---
315
- # store:
316
- # - PUT
317
- # - /<<index>>/<<type>>/<<id>>
318
- #
319
- # Usage:
320
- # Flex.store :id => id, # required
321
- # :type => nil,
322
- # :index => "flex_test_index"
323
- #
324
- def Flex.store(vars={})
325
- # this is a stub, used for reference
326
- end
327
-
328
-
329
- # ########## Flex.put_store ##########
330
- #
331
- # Flex::Template:
332
- # ---
333
- # put_store:
334
- # - PUT
335
- # - /<<index>>/<<type>>/<<id>>
336
- #
337
- # Usage:
338
- # Flex.put_store :id => id, # required
339
- # :type => nil,
340
- # :index => "flex_test_index"
341
- #
342
- def Flex.put_store(vars={})
343
- # this is a stub, used for reference
344
- end
345
-
346
-
347
- # ########## Flex.post_store ##########
348
- #
349
- # Flex::Template:
350
- # ---
351
- # post_store:
352
- # - POST
353
- # - /<<index>>/<<type>>
354
- #
355
- # Usage:
356
- # Flex.post_store :index => "flex_test_index",
357
- # :type => nil
358
- #
359
- def Flex.post_store(vars={})
360
- # this is a stub, used for reference
361
- end
362
-
363
-
364
- # ########## Flex.remove ##########
365
- #
366
- # Flex::Template:
367
- # ---
368
- # remove:
369
- # - DELETE
370
- # - /<<index>>/<<type>>/<<id>>
371
- #
372
- # Usage:
373
- # Flex.remove :id => id, # required
374
- # :type => nil,
375
- # :index => "flex_test_index"
376
- #
377
- def Flex.remove(vars={})
378
- # this is a stub, used for reference
379
- end
49
+ require 'flex/api_stubs'
50
+ require 'flex/tasks'
380
51
 
52
+ module Flex
381
53
 
382
- # ########## Flex.get ##########
383
- #
384
- # Flex::Template:
385
- # ---
386
- # get:
387
- # - GET
388
- # - /<<index>>/<<type>>/<<id>>
389
- #
390
- # Usage:
391
- # Flex.get :id => id, # required
392
- # :type => nil,
393
- # :index => "flex_test_index"
394
- #
395
- def Flex.get(vars={})
396
- # this is a stub, used for reference
397
- end
54
+ VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
55
+ LIB_PATHS = [ File.dirname(__FILE__) ]
398
56
 
399
57
 
400
- # ########## Flex.multi_get ##########
401
- #
402
- # Flex::Template:
403
- # ---
404
- # multi_get:
405
- # - GET
406
- # - /<<index>>/<<type>>/_mget
407
- # - ids: << ids >>
408
- #
409
- # Usage:
410
- # Flex.multi_get :ids => ids, # required
411
- # :type => nil,
412
- # :index => "flex_test_index"
413
- #
414
- def Flex.multi_get(vars={})
415
- # this is a stub, used for reference
416
- end
58
+ include ApiStubs
417
59
 
418
- include Loader
419
- flex.load_source File.expand_path('../flex/api_methods.yml', __FILE__)
60
+ include Templates
61
+ flex.load_source File.expand_path('../flex/api_templates/core_api.yml' , __FILE__)
62
+ flex.load_source File.expand_path('../flex/api_templates/indices_api.yml', __FILE__)
63
+ flex.load_source File.expand_path('../flex/api_templates/cluster_api.yml', __FILE__)
420
64
 
421
65
  extend self
422
66
  extend UtilityMethods
423
67
 
424
- def reload!
425
- flex.variables = Configuration.variables.deep_dup
426
- Loader.host_classes.each {|c| c.flex.reload!}
427
- true
428
- end
429
-
430
- def info(*args)
431
- flex.info *args
68
+ flex.wrap :post_bulk_string, :bulk do |*vars|
69
+ vars = Vars.new(*vars)
70
+ return if vars[:bulk_string].nil? || vars[:bulk_string].empty?
71
+ super vars
72
+ end
73
+
74
+ # get a document without using the get API (which doesn't support fields '*')
75
+ flex.wrap :search_by_id do |*vars|
76
+ vars = Vars.new(*vars)
77
+ result = super(vars)
78
+ doc = result['hits']['hits'].first
79
+ class << doc; self end.class_eval do
80
+ define_method(:raw_result){ result }
81
+ end
82
+ doc
83
+ end
84
+
85
+ # support for live-reindex
86
+ flex.wrap :store, :put_store, :post_store do |*vars|
87
+ vars = Vars.new(*vars)
88
+ vars[:index] = LiveReindex.prefix_index(vars[:index]) if LiveReindex.should_prefix_index?
89
+ result = super(vars)
90
+ if LiveReindex.should_track_change?
91
+ vars.delete(:data)
92
+ LiveReindex.track_change(:index, dump_one(vars))
93
+ end
94
+ result
95
+ end
96
+
97
+ # support for live-reindex
98
+ flex.wrap :delete, :remove do |*vars|
99
+ vars = Vars.new(*vars)
100
+ vars[:index] = LiveReindex.prefix_index(vars[:index]) if LiveReindex.should_prefix_index?
101
+ if LiveReindex.should_track_change?
102
+ vars.delete(:data)
103
+ LiveReindex.track_change(:delete, dump_one(vars))
104
+ end
105
+ super(vars)
432
106
  end
433
107
 
434
108
  end