Skip to content
Newer
Older
100644 223 lines (167 sloc) 7.75 KB
b1721ac @kimchy remove version from readme
kimchy authored Apr 20, 2010
1 h1. ElasticSearch
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
2
3 h2. A Distributed RESTful Search Engine
4
1d6fa98 @kimchy change to elasticsearch.org site
kimchy authored Sep 26, 2011
5 h3. "http://www.elasticsearch.org":http://www.elasticsearch.org
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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.
c31d29b @kimchy fix readme to use replica and not backup for shards
kimchy authored Feb 14, 2010
11 ** Each shard can have one or more replicas.
12 ** Read / Search operations performed on either one of the replica shard.
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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
b9245a9 @jgeiger Fix typo
jgeiger authored Apr 26, 2011
35 First of all, DON'T PANIC. It will take 5 minutes to get the gist of what ElasticSearch is all about.
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
36
37 h3. Installation
38
6585b09 @kimchy add link to download in readme
kimchy authored Dec 8, 2011
39 * "Download":http://www.elasticsearch.org/download and unzip the ElasticSearch official distribution.
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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>
3e12600 @kimchy update readme
kimchy authored Apr 2, 2010
49 curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
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 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
64 </pre>
65
66 Now, lets see if the information was added by GETting it:
67
68 <pre>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
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'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
80 curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
81 </pre>
82
83 We can also use the JSON query language ElasticSearch provides instead of a query string:
84
85 <pre>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
86 curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
87 {
88 "query" : {
10108d9 @kimchy replace term query sample with text
kimchy authored May 14, 2011
89 "text" : { "user": "kimchy" }
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
90 }
91 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
92 </pre>
93
94 Just for kicks, lets get all the documents stored (we should see the user as well):
95
96 <pre>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
97 curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
98 {
99 "query" : {
100 "matchAll" : {}
101 }
102 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
103 </pre>
104
105 We can also do range search (the @postDate@ was automatically identified as date)
106
107 <pre>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
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 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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
d442acf @kimchy update README to reflect the local gateway default
kimchy authored Oct 24, 2010
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:
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
127
128 <pre>
3e12600 @kimchy update readme
kimchy authored Apr 2, 2010
129 curl -XPUT 'http://localhost:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
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 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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
c31d29b @kimchy fix readme to use replica and not backup for shards
kimchy authored Feb 14, 2010
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):
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
149
150 <pre>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
151 curl -XPUT http://localhost:9200/another_user/ -d '
152 {
153 "index" : {
154 "numberOfShards" : 1,
155 "numberOfReplicas" : 1
156 }
157 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
164 curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
165 {
166 "query" : {
167 "matchAll" : {}
168 }
169 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
170 </pre>
171
172 Or on all the indices:
173
174 <pre>
54dc5a5 @kimchy update readme file
kimchy authored Mar 6, 2010
175 curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
176 {
177 "query" : {
178 "matchAll" : {}
179 }
180 }'
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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
d442acf @kimchy update README to reflect the local gateway default
kimchy authored Oct 24, 2010
185 h3. Distributed, Highly Available
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
186
187 Lets face it, things will fail....
188
c31d29b @kimchy fix readme to use replica and not backup for shards
kimchy authored Feb 14, 2010
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).
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
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
19d80a7 @kimchy assemblies
kimchy authored Dec 6, 2011
199 ElasticSearch uses "Maven":http://maven.apache.org for its build system.
fb53afc @karmi README: Fixed typo and formatting in the „Building from Source” chapter
karmi authored Apr 21, 2011
200
074c70d @kimchy building dist should be using package
kimchy authored Dec 8, 2011
201 In order to create a distribution, simply run the @mvn package -DskipTests@ command in the cloned directory.
fb53afc @karmi README: Fixed typo and formatting in the „Building from Source” chapter
karmi authored Apr 21, 2011
202
19d80a7 @kimchy assemblies
kimchy authored Dec 6, 2011
203 The distribution will be created under @target/releases@.
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
204
205 h1. License
206
207 <pre>
208 This software is licensed under the Apache 2 license, quoted below.
209
0ec8cb1 @kimchy update copyright
kimchy authored Jul 31, 2012
210 Copyright 2009-2012 Shay Banon and ElasticSearch <http://www.elasticsearch.org>
b3337c3 @kimchy initial commit
kimchy authored Feb 8, 2010
211
212 Licensed under the Apache License, Version 2.0 (the "License"); you may not
213 use this file except in compliance with the License. You may obtain a copy of
214 the License at
215
216 http://www.apache.org/licenses/LICENSE-2.0
217
218 Unless required by applicable law or agreed to in writing, software
219 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
220 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
221 License for the specific language governing permissions and limitations under
222 the License.
223 </pre>
Something went wrong with that request. Please try again.