fluent-plugin-embedded-elasticsearch 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +46 -0
  3. data/conf/example.conf +32 -0
  4. data/lib/fluent/plugin/in_embedded_elasticsearch.rb +52 -0
  5. data/vendor/elasticsearch/LICENSE.txt +202 -0
  6. data/vendor/elasticsearch/NOTICE.txt +5 -0
  7. data/vendor/elasticsearch/README.textile +227 -0
  8. data/vendor/elasticsearch/bin/elasticsearch +184 -0
  9. data/vendor/elasticsearch/bin/elasticsearch-service-mgr.exe +0 -0
  10. data/vendor/elasticsearch/bin/elasticsearch-service-x64.exe +0 -0
  11. data/vendor/elasticsearch/bin/elasticsearch-service-x86.exe +0 -0
  12. data/vendor/elasticsearch/bin/elasticsearch.bat +79 -0
  13. data/vendor/elasticsearch/bin/elasticsearch.in.sh +64 -0
  14. data/vendor/elasticsearch/bin/plugin +49 -0
  15. data/vendor/elasticsearch/bin/plugin.bat +22 -0
  16. data/vendor/elasticsearch/bin/service.bat +231 -0
  17. data/vendor/elasticsearch/config/elasticsearch.yml +364 -0
  18. data/vendor/elasticsearch/config/logging.yml +56 -0
  19. data/vendor/elasticsearch/lib/elasticsearch-0.90.7.jar +0 -0
  20. data/vendor/elasticsearch/lib/jna-3.3.0.jar +0 -0
  21. data/vendor/elasticsearch/lib/jts-1.12.jar +0 -0
  22. data/vendor/elasticsearch/lib/log4j-1.2.17.jar +0 -0
  23. data/vendor/elasticsearch/lib/lucene-analyzers-common-4.5.1.jar +0 -0
  24. data/vendor/elasticsearch/lib/lucene-codecs-4.5.1.jar +0 -0
  25. data/vendor/elasticsearch/lib/lucene-core-4.5.1.jar +0 -0
  26. data/vendor/elasticsearch/lib/lucene-grouping-4.5.1.jar +0 -0
  27. data/vendor/elasticsearch/lib/lucene-highlighter-4.5.1.jar +0 -0
  28. data/vendor/elasticsearch/lib/lucene-join-4.5.1.jar +0 -0
  29. data/vendor/elasticsearch/lib/lucene-memory-4.5.1.jar +0 -0
  30. data/vendor/elasticsearch/lib/lucene-misc-4.5.1.jar +0 -0
  31. data/vendor/elasticsearch/lib/lucene-queries-4.5.1.jar +0 -0
  32. data/vendor/elasticsearch/lib/lucene-queryparser-4.5.1.jar +0 -0
  33. data/vendor/elasticsearch/lib/lucene-sandbox-4.5.1.jar +0 -0
  34. data/vendor/elasticsearch/lib/lucene-spatial-4.5.1.jar +0 -0
  35. data/vendor/elasticsearch/lib/lucene-suggest-4.5.1.jar +0 -0
  36. data/vendor/elasticsearch/lib/sigar/libsigar-amd64-freebsd-6.so +0 -0
  37. data/vendor/elasticsearch/lib/sigar/libsigar-amd64-linux.so +0 -0
  38. data/vendor/elasticsearch/lib/sigar/libsigar-amd64-solaris.so +0 -0
  39. data/vendor/elasticsearch/lib/sigar/libsigar-ia64-linux.so +0 -0
  40. data/vendor/elasticsearch/lib/sigar/libsigar-sparc-solaris.so +0 -0
  41. data/vendor/elasticsearch/lib/sigar/libsigar-sparc64-solaris.so +0 -0
  42. data/vendor/elasticsearch/lib/sigar/libsigar-universal-macosx.dylib +0 -0
  43. data/vendor/elasticsearch/lib/sigar/libsigar-universal64-macosx.dylib +0 -0
  44. data/vendor/elasticsearch/lib/sigar/libsigar-x86-freebsd-5.so +0 -0
  45. data/vendor/elasticsearch/lib/sigar/libsigar-x86-freebsd-6.so +0 -0
  46. data/vendor/elasticsearch/lib/sigar/libsigar-x86-linux.so +0 -0
  47. data/vendor/elasticsearch/lib/sigar/libsigar-x86-solaris.so +0 -0
  48. data/vendor/elasticsearch/lib/sigar/sigar-1.6.4.jar +0 -0
  49. data/vendor/elasticsearch/lib/sigar/sigar-amd64-winnt.dll +0 -0
  50. data/vendor/elasticsearch/lib/sigar/sigar-x86-winnt.dll +0 -0
  51. data/vendor/elasticsearch/lib/sigar/sigar-x86-winnt.lib +0 -0
  52. data/vendor/elasticsearch/lib/spatial4j-0.3.jar +0 -0
  53. metadata +109 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 621bf06d745ee49ec9386b74e99f4abe0c4e6e6e
4
+ data.tar.gz: 781dec304a1450ab366830e606079e09da79236c
5
+ SHA512:
6
+ metadata.gz: 635ad865b7396ea94397b13bbf04c63d641f7cd332c6253593642f97deb9935b8368df56ba510a17f13e9472aafd2758e5c88682a6485d14b31bd9f224315854
7
+ data.tar.gz: 3548ff220e086e0cdb397108d10522290975a813a44c2b6612523a582eb7d9f973c3d1f87e5eaaffc7fb53b2cfc68c065f6306e5f08a88449ccda8ed24726800
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ #Embedded ElasticSearch for Fluentd
2
+
3
+ This plugin launches a local ElasticSearch process inside Fluentd.
4
+ ElasticSearch's version is 0.90-RC2.
5
+
6
+ ## Installation
7
+
8
+ Use RubyGems:
9
+
10
+ gem install fluent-plugin-embedded-elasticsearch
11
+
12
+ ## Configuration
13
+
14
+ <source>
15
+ type embedded_elasticsearch
16
+ </source>
17
+
18
+ Also, please see "conf/example.conf" for an example configuration with
19
+ [fluent-plugin-kibana-server](http://github.com/choplin/fluent-plugin-kibana-server) and
20
+ [fluent-plugin-elasticsearch](http://github.com/uken/fluent-plugin-elasticsearch).
21
+
22
+ ## TODO
23
+
24
+ Figure out what ElasticSearch options are useful. Right now, `elasticsearch -f
25
+ -Des.index.store=memory` is hard-coded, but all the ES options should be
26
+ configurable (either via -Des.config or inlining). **Pull requests are
27
+ welcomed!**
28
+
29
+ ## Notes
30
+
31
+ * Thanks to folks over at Logstash for the "embedding" idea.
32
+ * Thanks to @frsyuki for [ServerEngine](https://github.com/frsyuki/serverengine)
33
+
34
+ ## Copyright
35
+
36
+ <table>
37
+ <tr>
38
+ <td>Author</td><td>Kiyoto Tamura<me@ktamura.com></td>
39
+ </tr>
40
+ <tr>
41
+ <td>Copyright</td><td>Copyright (c) 2013- Kiyoto Tamura</td>
42
+ </tr>
43
+ <tr>
44
+ <td>License</td><td>Apache 2.0 License</td>
45
+ </tr>
46
+ </table>
data/conf/example.conf ADDED
@@ -0,0 +1,32 @@
1
+
2
+ <source>
3
+ type embedded_elasticsearch
4
+ </source>
5
+
6
+ <source>
7
+ type kibana_server
8
+ bind 0.0.0.0
9
+ port 24300
10
+ mount /kibana/
11
+ access_log_path /var/log/kibana/access.log
12
+ elasticsearch_url http://localhost:9200
13
+ </source>
14
+
15
+ <source>
16
+ type http
17
+ port 8888
18
+ </source>
19
+
20
+ <match es.**>
21
+ type copy
22
+ <store>
23
+ type elasticsearch
24
+ logstash_format true
25
+ index_name fluentd
26
+ type_name fluentd
27
+ flush_interval 3
28
+ </store>
29
+ <store>
30
+ type stdout
31
+ </store>
32
+ </match>
@@ -0,0 +1,52 @@
1
+ require 'shellwords'
2
+ require 'serverengine'
3
+
4
+ module Fluent
5
+ class EmbeddedElasticSearchInput < Input
6
+ Plugin.register_input('embedded_elasticsearch', self)
7
+
8
+ DIR_PATH = File.dirname(__FILE__)
9
+
10
+ config_param :graceful_kill_interval, :time, :default => 2
11
+ config_param :graceful_kill_interval_increment, :time, :default => 3
12
+ config_param :graceful_kill_timeout, :time, :default => 60
13
+ config_param :bind, :string, :default => "localhost"
14
+ config_param :port, :string, :default => 9200
15
+ config_param :elasticsearch_dir, :string, :default => File.expand_path("#{DIR_PATH}/../../../vendor/elasticsearch/")
16
+
17
+ def configure(conf)
18
+ super
19
+ end
20
+
21
+ def start
22
+ @pm = ServerEngine::ProcessManager.new(
23
+ :auto_tick => true,
24
+ :auto_tick_interval => 1,
25
+ :graceful_kill_interval => @graceful_kill_interval,
26
+ :graceful_kill_interval_increment => @graceful_kill_interval_increment,
27
+ :graceful_kill_timeout => @graceful_kill_timeout,
28
+ :graceful_kill_signal => 'TERM',
29
+ :immediate_kill_timeout => 0, # disabled
30
+ )
31
+
32
+ $log.info "Launching ElasticSearch #{@bind}:#{@port} with #{@elasticsearch_dir}"
33
+ @process_monitor = @pm.spawn(elasticsearch_command)
34
+ end
35
+
36
+ def shutdown
37
+ $log.info "Shutting down ElasticSearch"
38
+
39
+ if @process_monitor
40
+ @process_monitor.start_graceful_stop!
41
+ @process_monitor.join
42
+ end
43
+ end
44
+
45
+ def elasticsearch_command
46
+ elasticsearch_binary = "#{@elasticsearch_dir}/bin/elasticsearch"
47
+ options = ["-f", "-Des.index.store=memory"] # -f ensures it runs in the (ServerEngine) foreground
48
+ "#{elasticsearch_binary} #{options.join(" ")}"
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ ElasticSearch
2
+ Copyright 2009-2011 ElasticSearch and Shay Banon
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,227 @@
1
+ h1. ElasticSearch
2
+
3
+ h2. A Distributed RESTful Search Engine
4
+
5
+ h3. "http://www.elasticsearch.org":http://www.elasticsearch.org
6
+
7
+ ElasticSearch is a distributed RESTful search engine built for the cloud. Features include:
8
+
9
+ * Distributed and Highly Available Search Engine.
10
+ ** Each index is fully sharded with a configurable number of shards.
11
+ ** Each shard can have one or more replicas.
12
+ ** Read / Search operations performed on either one of the replica shard.
13
+ * Multi Tenant with Multi Types.
14
+ ** Support for more than one index.
15
+ ** Support for more than one type per index.
16
+ ** Index level configuration (number of shards, index storage, ...).
17
+ * Various set of APIs
18
+ ** HTTP RESTful API
19
+ ** Native Java API.
20
+ ** All APIs perform automatic node operation rerouting.
21
+ * Document oriented
22
+ ** No need for upfront schema definition.
23
+ ** Schema can be defined per type for customization of the indexing process.
24
+ * Reliable, Asynchronous Write Behind for long term persistency.
25
+ * (Near) Real Time Search.
26
+ * Built on top of Lucene
27
+ ** Each shard is a fully functional Lucene index
28
+ ** All the power of Lucene easily exposed through simple configuration / plugins.
29
+ * Per operation consistency
30
+ ** Single document level operations are atomic, consistent, isolated and durable.
31
+ * Open Source under Apache 2 License.
32
+
33
+ h2. Getting Started
34
+
35
+ First of all, DON'T PANIC. It will take 5 minutes to get the gist of what ElasticSearch is all about.
36
+
37
+ h3. Installation
38
+
39
+ * "Download":http://www.elasticsearch.org/download and unzip the ElasticSearch official distribution.
40
+ * Run @bin/elasticsearch -f@ on unix, or @bin/elasticsearch.bat@ on windows.
41
+ * Run @curl -X GET http://localhost:9200/@.
42
+ * Start more servers ...
43
+
44
+ h3. Indexing
45
+
46
+ Lets try and index some twitter like information. First, lets create a twitter user, and add some tweets (the @twitter@ index will be created automatically):
47
+
48
+ <pre>
49
+ curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
50
+
51
+ curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
52
+ {
53
+ "user": "kimchy",
54
+ "postDate": "2009-11-15T13:12:00",
55
+ "message": "Trying out Elastic Search, so far so good?"
56
+ }'
57
+
58
+ curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
59
+ {
60
+ "user": "kimchy",
61
+ "postDate": "2009-11-15T14:12:12",
62
+ "message": "Another tweet, will it be indexed?"
63
+ }'
64
+ </pre>
65
+
66
+ Now, lets see if the information was added by GETting it:
67
+
68
+ <pre>
69
+ curl -XGET 'http://localhost:9200/twitter/user/kimchy?pretty=true'
70
+ curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
71
+ curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
72
+ </pre>
73
+
74
+ h3. Searching
75
+
76
+ Mmm search..., shouldn't it be elastic?
77
+ Lets find all the tweets that @kimchy@ posted:
78
+
79
+ <pre>
80
+ curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
81
+ </pre>
82
+
83
+ We can also use the JSON query language ElasticSearch provides instead of a query string:
84
+
85
+ <pre>
86
+ curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
87
+ {
88
+ "query" : {
89
+ "text" : { "user": "kimchy" }
90
+ }
91
+ }'
92
+ </pre>
93
+
94
+ Just for kicks, lets get all the documents stored (we should see the user as well):
95
+
96
+ <pre>
97
+ curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
98
+ {
99
+ "query" : {
100
+ "matchAll" : {}
101
+ }
102
+ }'
103
+ </pre>
104
+
105
+ We can also do range search (the @postDate@ was automatically identified as date)
106
+
107
+ <pre>
108
+ curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
109
+ {
110
+ "query" : {
111
+ "range" : {
112
+ "postDate" : { "from" : "2009-11-15T13:00:00", "to" : "2009-11-15T14:00:00" }
113
+ }
114
+ }
115
+ }'
116
+ </pre>
117
+
118
+ There are many more options to perform search, after all, its a search product no? All the familiar Lucene queries are available through the JSON query language, or through the query parser.
119
+
120
+ h3. Multi Tenant - Indices and Types
121
+
122
+ Maan, that twitter index might get big (in this case, index size == valuation). Lets see if we can structure our twitter system a bit differently in order to support such large amount of data.
123
+
124
+ ElasticSearch support multiple indices, as well as multiple types per index. In the previous example we used an index called @twitter@, with two types, @user@ and @tweet@.
125
+
126
+ Another way to define our simple twitter system is to have a different index per user (though note that an index has an overhead). Here is the indexing curl's in this case:
127
+
128
+ <pre>
129
+ curl -XPUT 'http://localhost:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
130
+
131
+ curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
132
+ {
133
+ "user": "kimchy",
134
+ "postDate": "2009-11-15T13:12:00",
135
+ "message": "Trying out Elastic Search, so far so good?"
136
+ }'
137
+
138
+ curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
139
+ {
140
+ "user": "kimchy",
141
+ "postDate": "2009-11-15T14:12:12",
142
+ "message": "Another tweet, will it be indexed?"
143
+ }'
144
+ </pre>
145
+
146
+ The above index information into the @kimchy@ index, with two types, @info@ and @tweet@. Each user will get his own special index.
147
+
148
+ Complete control on the index level is allowed. As an example, in the above case, we would want to change from the default 5 shards with 1 replica per index, to only 1 shard with 1 replica per index (== per twitter user). Here is how this can be done (the configuration can be in yaml as well):
149
+
150
+ <pre>
151
+ curl -XPUT http://localhost:9200/another_user/ -d '
152
+ {
153
+ "index" : {
154
+ "numberOfShards" : 1,
155
+ "numberOfReplicas" : 1
156
+ }
157
+ }'
158
+ </pre>
159
+
160
+ Search (and similar operations) are multi index aware. This means that we can easily search on more than one
161
+ index (twitter user), for example:
162
+
163
+ <pre>
164
+ curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
165
+ {
166
+ "query" : {
167
+ "matchAll" : {}
168
+ }
169
+ }'
170
+ </pre>
171
+
172
+ Or on all the indices:
173
+
174
+ <pre>
175
+ curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
176
+ {
177
+ "query" : {
178
+ "matchAll" : {}
179
+ }
180
+ }'
181
+ </pre>
182
+
183
+ {One liner teaser}: And the cool part about that? You can easily search on multiple twitter users (indices), with different boost levels per user (index), making social search so much simpler (results from my friends rank higher than results from my friends friends).
184
+
185
+ h3. Distributed, Highly Available
186
+
187
+ Lets face it, things will fail....
188
+
189
+ ElasticSearch is a highly available and distributed search engine. Each index is broken down into shards, and each shard can have one or more replica. By default, an index is created with 5 shards and 1 replica per shard (5/1). There are many topologies that can be used, including 1/10 (improve search performance), or 20/1 (improve indexing performance, with search executed in a map reduce fashion across shards).
190
+
191
+ In order to play with Elastic Search distributed nature, simply bring more nodes up and shut down nodes. The system will continue to serve requests (make sure you use the correct http port) with the latest data indexed.
192
+
193
+ h3. Where to go from here?
194
+
195
+ We have just covered a very small portion of what ElasticSearch is all about. For more information, please refer to: .
196
+
197
+ h3. Building from Source
198
+
199
+ ElasticSearch uses "Maven":http://maven.apache.org for its build system.
200
+
201
+ In order to create a distribution, simply run the @mvn clean package
202
+ -DskipTests@ command in the cloned directory.
203
+
204
+ The distribution will be created under @target/releases@.
205
+
206
+ See the "TESTING":TESTING.asciidoc file for more information about
207
+ running the Elasticsearch test suite.
208
+
209
+ h1. License
210
+
211
+ <pre>
212
+ This software is licensed under the Apache 2 license, quoted below.
213
+
214
+ Copyright 2009-2013 Shay Banon and ElasticSearch <http://www.elasticsearch.org>
215
+
216
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
217
+ use this file except in compliance with the License. You may obtain a copy of
218
+ the License at
219
+
220
+ http://www.apache.org/licenses/LICENSE-2.0
221
+
222
+ Unless required by applicable law or agreed to in writing, software
223
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
224
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
225
+ License for the specific language governing permissions and limitations under
226
+ the License.
227
+ </pre>