flex 0.4.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +46 -7
- data/VERSION +1 -1
- data/flex.gemspec +13 -19
- data/lib/flex.rb +66 -392
- data/lib/flex/api_stubs.rb +1268 -0
- data/lib/flex/api_templates/cluster_api.yml +94 -0
- data/lib/flex/api_templates/core_api.yml +202 -0
- data/lib/flex/api_templates/indices_api.yml +304 -0
- data/lib/flex/class_proxy/base.rb +20 -6
- data/lib/flex/class_proxy/templates.rb +97 -0
- data/lib/flex/class_proxy/templates/doc.rb +91 -0
- data/lib/flex/class_proxy/templates/search.rb +72 -0
- data/lib/flex/configuration.rb +17 -49
- data/lib/flex/deprecation.rb +153 -0
- data/lib/flex/errors.rb +2 -1
- data/lib/flex/http_clients/base.rb +15 -0
- data/lib/flex/http_clients/loader.rb +51 -0
- data/lib/flex/http_clients/patron.rb +9 -7
- data/lib/flex/http_clients/rest_client.rb +6 -8
- data/lib/flex/logger.rb +24 -3
- data/lib/flex/prog_bar.rb +11 -6
- data/lib/flex/rails.rb +1 -13
- data/lib/flex/result.rb +8 -2
- data/lib/flex/result/document.rb +42 -13
- data/lib/flex/result/multi_get.rb +24 -0
- data/lib/flex/result/search.rb +1 -24
- data/lib/flex/struct/array.rb +25 -0
- data/lib/flex/struct/hash.rb +105 -0
- data/lib/flex/{result/collection.rb → struct/paginable.rb} +16 -9
- data/lib/flex/struct/prunable.rb +60 -0
- data/lib/flex/struct/symbolize.rb +27 -0
- data/lib/flex/tasks.rb +26 -86
- data/lib/flex/template.rb +60 -120
- data/lib/flex/template/common.rb +42 -0
- data/lib/flex/template/logger.rb +66 -0
- data/lib/flex/template/partial.rb +12 -15
- data/lib/flex/template/search.rb +6 -6
- data/lib/flex/template/slim_search.rb +1 -1
- data/lib/flex/template/tags.rb +19 -9
- data/lib/flex/templates.rb +20 -0
- data/lib/flex/utility_methods.rb +80 -89
- data/lib/flex/utils.rb +68 -25
- data/lib/flex/variables.rb +55 -4
- data/lib/tasks.rake +28 -0
- metadata +61 -85
- data/bin/flexes +0 -174
- data/lib/flex/api_methods.yml +0 -108
- data/lib/flex/class_proxy/loader.rb +0 -102
- data/lib/flex/class_proxy/model.rb +0 -45
- data/lib/flex/class_proxy/model_sync.rb +0 -23
- data/lib/flex/class_proxy/related_model.rb +0 -23
- data/lib/flex/instance_proxy/base.rb +0 -29
- data/lib/flex/instance_proxy/model.rb +0 -102
- data/lib/flex/instance_proxy/related_model.rb +0 -7
- data/lib/flex/loader.rb +0 -18
- data/lib/flex/manager.rb +0 -61
- data/lib/flex/model.rb +0 -24
- data/lib/flex/rails/engine.rb +0 -23
- data/lib/flex/rails/helper.rb +0 -16
- data/lib/flex/related_model.rb +0 -16
- data/lib/flex/result/indifferent_access.rb +0 -11
- data/lib/flex/result/source_document.rb +0 -63
- data/lib/flex/result/source_search.rb +0 -32
- data/lib/flex/structure/indifferent_access.rb +0 -44
- data/lib/flex/structure/mergeable.rb +0 -21
- data/lib/flex/template/base.rb +0 -41
- data/lib/flex/template/info.rb +0 -68
- data/lib/generators/flex/setup/setup_generator.rb +0 -48
- data/lib/generators/flex/setup/templates/flex_config.yml +0 -16
- data/lib/generators/flex/setup/templates/flex_dir/es.rb.erb +0 -18
- data/lib/generators/flex/setup/templates/flex_dir/es.yml.erb +0 -19
- data/lib/generators/flex/setup/templates/flex_dir/es_extender.rb.erb +0 -17
- data/lib/generators/flex/setup/templates/flex_initializer.rb.erb +0 -44
- data/lib/tasks/index.rake +0 -17
- data/test/flex.irt +0 -143
- data/test/flex/configuration.irt +0 -53
- data/test/irt_helper.rb +0 -12
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,51 @@
|
|
1
1
|
# Flex
|
2
2
|
|
3
|
-
Flex is
|
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
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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](
|
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.
|
1
|
+
1.0.1
|
data/flex.gemspec
CHANGED
@@ -2,20 +2,23 @@ require 'date'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'flex'
|
5
|
-
s.summary = '
|
5
|
+
s.summary = 'The ultimate ruby client for elasticsearch'
|
6
6
|
s.description = <<-desc
|
7
|
-
Flex is
|
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 = [
|
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 =
|
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
|
-
|
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
|
-
|
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
|
39
|
-
s.add_runtime_dependency
|
40
|
-
s.add_runtime_dependency
|
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
|
data/lib/flex.rb
CHANGED
@@ -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/
|
10
|
-
require 'flex/
|
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/
|
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/
|
21
|
+
require 'flex/result/multi_get'
|
18
22
|
require 'flex/result/bulk'
|
19
23
|
|
20
|
-
require 'flex/
|
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/
|
34
|
-
require 'flex/class_proxy/
|
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/
|
39
|
-
require 'flex/instance_proxy/model'
|
40
|
-
require 'flex/instance_proxy/related_model'
|
36
|
+
require 'flex/class_proxy/templates'
|
41
37
|
|
42
|
-
require 'flex/
|
43
|
-
require 'flex/related_model'
|
44
|
-
require 'flex/model'
|
38
|
+
require 'flex/templates'
|
45
39
|
|
46
|
-
require 'flex/http_clients/
|
47
|
-
require 'flex/http_clients/
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
419
|
-
flex.load_source File.expand_path('../flex/
|
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
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
end
|
429
|
-
|
430
|
-
|
431
|
-
|
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
|