Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 232 lines (172 sloc) 8.438 kb
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
1 h1. Elasticsearch
b3337c3 @kimchy initial commit
kimchy authored
2
3 h2. A Distributed RESTful Search Engine
4
1d6fa98 @kimchy change to elasticsearch.org site
kimchy authored
5 h3. "http://www.elasticsearch.org":http://www.elasticsearch.org
b3337c3 @kimchy initial commit
kimchy authored
6
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
7 Elasticsearch is a distributed RESTful search engine built for the cloud. Features include:
b3337c3 @kimchy initial commit
kimchy authored
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
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
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.
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
31 * Open Source under the Apache License, version 2 ("ALv2")
b3337c3 @kimchy initial commit
kimchy authored
32
33 h2. Getting Started
34
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
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
36
37 h3. Installation
38
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
39 * "Download":http://www.elasticsearch.org/download and unzip the Elasticsearch official distribution.
5ebc238 @clintongormley Docs: Changed the path separator for Windows in the README
clintongormley authored
40 * Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
b3337c3 @kimchy initial commit
kimchy authored
41 * Run @curl -X GET http://localhost:9200/@.
42 * Start more servers ...
43
44 h3. Indexing
45
215df2e @Paikan foreground mode is now the default, s/lets/let's/
Paikan authored
46 Let's try and index some twitter like information. First, let's create a twitter user, and add some tweets (the @twitter@ index will be created automatically):
b3337c3 @kimchy initial commit
kimchy authored
47
48 <pre>
3e12600 @kimchy update readme
kimchy authored
49 curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
54dc5a5 @kimchy update readme file
kimchy authored
50
51 curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
52 {
53 "user": "kimchy",
54 "postDate": "2009-11-15T13:12:00",
55 "message": "Trying out Elasticsearch, so far so good?"
54dc5a5 @kimchy update readme file
kimchy authored
56 }'
57
58 curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
59 {
60 "user": "kimchy",
61 "postDate": "2009-11-15T14:12:12",
62 "message": "Another tweet, will it be indexed?"
54dc5a5 @kimchy update readme file
kimchy authored
63 }'
b3337c3 @kimchy initial commit
kimchy authored
64 </pre>
65
215df2e @Paikan foreground mode is now the default, s/lets/let's/
Paikan authored
66 Now, let's see if the information was added by GETting it:
b3337c3 @kimchy initial commit
kimchy authored
67
68 <pre>
54dc5a5 @kimchy update readme file
kimchy authored
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
72 </pre>
73
74 h3. Searching
75
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
76 Mmm search..., shouldn't it be elastic?
215df2e @Paikan foreground mode is now the default, s/lets/let's/
Paikan authored
77 Let's find all the tweets that @kimchy@ posted:
b3337c3 @kimchy initial commit
kimchy authored
78
79 <pre>
54dc5a5 @kimchy update readme file
kimchy authored
80 curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
b3337c3 @kimchy initial commit
kimchy authored
81 </pre>
82
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
83 We can also use the JSON query language Elasticsearch provides instead of a query string:
b3337c3 @kimchy initial commit
kimchy authored
84
85 <pre>
54dc5a5 @kimchy update readme file
kimchy authored
86 curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
87 {
88 "query" : {
0cebbf1 @dadoonet Text Query has been replaced by Match Query
dadoonet authored
89 "match" : { "user": "kimchy" }
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
90 }
54dc5a5 @kimchy update readme file
kimchy authored
91 }'
b3337c3 @kimchy initial commit
kimchy authored
92 </pre>
93
215df2e @Paikan foreground mode is now the default, s/lets/let's/
Paikan authored
94 Just for kicks, let's get all the documents stored (we should see the user as well):
b3337c3 @kimchy initial commit
kimchy authored
95
96 <pre>
54dc5a5 @kimchy update readme file
kimchy authored
97 curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
98 {
99 "query" : {
100 "matchAll" : {}
101 }
54dc5a5 @kimchy update readme file
kimchy authored
102 }'
b3337c3 @kimchy initial commit
kimchy authored
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
108 curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
109 {
110 "query" : {
111 "range" : {
112 "postDate" : { "from" : "2009-11-15T13:00:00", "to" : "2009-11-15T14:00:00" }
113 }
114 }
54dc5a5 @kimchy update readme file
kimchy authored
115 }'
b3337c3 @kimchy initial commit
kimchy authored
116 </pre>
117
59417f9 @philfreo Docs: Fix minor typo in readme
philfreo authored
118 There are many more options to perform search, after all, it's a search product no? All the familiar Lucene queries are available through the JSON query language, or through the query parser.
b3337c3 @kimchy initial commit
kimchy authored
119
120 h3. Multi Tenant - Indices and Types
121
ca6555b @chrismattmann Docs: Fix some typos, and sentence structure.
chrismattmann authored
122 Maan, that twitter index might get big (in this case, index size == valuation). Let's see if we can structure our twitter system a bit differently in order to support such large amounts of data.
b3337c3 @kimchy initial commit
kimchy authored
123
ca6555b @chrismattmann Docs: Fix some typos, and sentence structure.
chrismattmann authored
124 Elasticsearch supports 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@.
b3337c3 @kimchy initial commit
kimchy authored
125
ca6555b @chrismattmann Docs: Fix some typos, and sentence structure.
chrismattmann authored
126 Another way to define our simple twitter system is to have a different index per user (note, though that each index has an overhead). Here is the indexing curl's in this case:
b3337c3 @kimchy initial commit
kimchy authored
127
128 <pre>
3e12600 @kimchy update readme
kimchy authored
129 curl -XPUT 'http://localhost:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
54dc5a5 @kimchy update readme file
kimchy authored
130
131 curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
132 {
133 "user": "kimchy",
134 "postDate": "2009-11-15T13:12:00",
135 "message": "Trying out Elasticsearch, so far so good?"
54dc5a5 @kimchy update readme file
kimchy authored
136 }'
137
138 curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
139 {
140 "user": "kimchy",
141 "postDate": "2009-11-15T14:12:12",
142 "message": "Another tweet, will it be indexed?"
54dc5a5 @kimchy update readme file
kimchy authored
143 }'
b3337c3 @kimchy initial commit
kimchy authored
144 </pre>
145
ca6555b @chrismattmann Docs: Fix some typos, and sentence structure.
chrismattmann authored
146 The above will index information into the @kimchy@ index, with two types, @info@ and @tweet@. Each user will get his own special index.
b3337c3 @kimchy initial commit
kimchy authored
147
c31d29b @kimchy fix readme to use replica and not backup for shards
kimchy authored
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
149
150 <pre>
54dc5a5 @kimchy update readme file
kimchy authored
151 curl -XPUT http://localhost:9200/another_user/ -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
152 {
153 "index" : {
154 "numberOfShards" : 1,
155 "numberOfReplicas" : 1
156 }
54dc5a5 @kimchy update readme file
kimchy authored
157 }'
b3337c3 @kimchy initial commit
kimchy authored
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
164 curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
165 {
166 "query" : {
167 "matchAll" : {}
168 }
54dc5a5 @kimchy update readme file
kimchy authored
169 }'
b3337c3 @kimchy initial commit
kimchy authored
170 </pre>
171
172 Or on all the indices:
173
174 <pre>
54dc5a5 @kimchy update readme file
kimchy authored
175 curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
176 {
177 "query" : {
178 "matchAll" : {}
179 }
54dc5a5 @kimchy update readme file
kimchy authored
180 }'
b3337c3 @kimchy initial commit
kimchy authored
181 </pre>
182
ca6555b @chrismattmann Docs: Fix some typos, and sentence structure.
chrismattmann authored
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 friends of my friends).
b3337c3 @kimchy initial commit
kimchy authored
184
d442acf @kimchy update README to reflect the local gateway default
kimchy authored
185 h3. Distributed, Highly Available
b3337c3 @kimchy initial commit
kimchy authored
186
215df2e @Paikan foreground mode is now the default, s/lets/let's/
Paikan authored
187 Let's face it, things will fail....
b3337c3 @kimchy initial commit
kimchy authored
188
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
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
190
ca6555b @chrismattmann Docs: Fix some typos, and sentence structure.
chrismattmann authored
191 In order to play with the distributed nature of Elasticsearch, 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.
b3337c3 @kimchy initial commit
kimchy authored
192
193 h3. Where to go from here?
194
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
195 We have just covered a very small portion of what Elasticsearch is all about. For more information, please refer to the "elasticsearch.org":http://www.elasticsearch.org website.
b3337c3 @kimchy initial commit
kimchy authored
196
197 h3. Building from Source
198
fa16969 @s1monw Cleanup comments and class names s/ElasticSearch/Elasticsearch
s1monw authored
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
200
92a7b24 @dakrone Add TESTING document describing test settings
dakrone authored
201 In order to create a distribution, simply run the @mvn clean package
202 -DskipTests@ command in the cloned directory.
fb53afc @karmi README: Fixed typo and formatting in the „Building from Source” chapter
karmi authored
203
19d80a7 @kimchy assemblies
kimchy authored
204 The distribution will be created under @target/releases@.
b3337c3 @kimchy initial commit
kimchy authored
205
92a7b24 @dakrone Add TESTING document describing test settings
dakrone authored
206 See the "TESTING":TESTING.asciidoc file for more information about
207 running the Elasticsearch test suite.
208
5138083 @seang-es Author: Sean Gallagher
seang-es authored
209 h3. Upgrading to Elasticsearch 1.x?
210
80ebd49 @seang-es [DOCS] Added tables and fixes to upgrade.asciidoc, fixed version in READ...
seang-es authored
211 In order to ensure a smooth upgrade process from earlier versions of Elasticsearch (< 1.0.0), it is recommended to perform a full cluster restart. Please see the "Upgrading" section of the "setup reference":http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html.
5138083 @seang-es Author: Sean Gallagher
seang-es authored
212
b3337c3 @kimchy initial commit
kimchy authored
213 h1. License
214
215 <pre>
f47fb6b @chrismattmann fix mention of Apache License, version 2.
chrismattmann authored
216 This software is licensed under the Apache License, version 2 ("ALv2"), quoted below.
b3337c3 @kimchy initial commit
kimchy authored
217
4d78026 @clintongormley Updated copyright years to include 2015
clintongormley authored
218 Copyright 2009-2015 Elasticsearch <http://www.elasticsearch.org>
b3337c3 @kimchy initial commit
kimchy authored
219
220 Licensed under the Apache License, Version 2.0 (the "License"); you may not
221 use this file except in compliance with the License. You may obtain a copy of
222 the License at
223
224 http://www.apache.org/licenses/LICENSE-2.0
225
226 Unless required by applicable law or agreed to in writing, software
227 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
228 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
229 License for the specific language governing permissions and limitations under
230 the License.
59ea426 @juanpastas Update README.textile
juanpastas authored
231 </pre>
Something went wrong with that request. Please try again.