|
@@ -28,7 +28,7 @@ Elasticsearch is a distributed RESTful search engine built for the cloud. Featur
|
|
|
** All the power of Lucene easily exposed through simple configuration / plugins.
|
|
** All the power of Lucene easily exposed through simple configuration / plugins.
|
|
|
* Per operation consistency
|
|
* Per operation consistency
|
|
|
** Single document level operations are atomic, consistent, isolated and durable.
|
|
** Single document level operations are atomic, consistent, isolated and durable.
|
|
|
-* Open Source under Apache 2 License.
|
|
|
|
|
|
|
+* Open Source under the Apache License, version 2 ("ALv2")
|
|
|
|
|
|
|
|
h2. Getting Started
|
|
h2. Getting Started
|
|
|
|
|
|
|
@@ -49,17 +49,17 @@ Let's try and index some twitter like information. First, let's create a twitter
|
|
|
curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
|
curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
|
|
|
|
|
|
|
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
|
|
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
|
|
|
-{
|
|
|
|
|
- "user": "kimchy",
|
|
|
|
|
- "postDate": "2009-11-15T13:12:00",
|
|
|
|
|
- "message": "Trying out Elasticsearch, so far so good?"
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "user": "kimchy",
|
|
|
|
|
+ "postDate": "2009-11-15T13:12:00",
|
|
|
|
|
+ "message": "Trying out Elasticsearch, so far so good?"
|
|
|
}'
|
|
}'
|
|
|
|
|
|
|
|
curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
|
curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
|
|
-{
|
|
|
|
|
- "user": "kimchy",
|
|
|
|
|
- "postDate": "2009-11-15T14:12:12",
|
|
|
|
|
- "message": "Another tweet, will it be indexed?"
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "user": "kimchy",
|
|
|
|
|
+ "postDate": "2009-11-15T14:12:12",
|
|
|
|
|
+ "message": "Another tweet, will it be indexed?"
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -73,7 +73,7 @@ curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
|
|
|
|
|
|
|
|
h3. Searching
|
|
h3. Searching
|
|
|
|
|
|
|
|
-Mmm search..., shouldn't it be elastic?
|
|
|
|
|
|
|
+Mmm search..., shouldn't it be elastic?
|
|
|
Let's find all the tweets that @kimchy@ posted:
|
|
Let's find all the tweets that @kimchy@ posted:
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
@@ -84,10 +84,10 @@ We can also use the JSON query language Elasticsearch provides instead of a quer
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
|
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
|
|
-{
|
|
|
|
|
- "query" : {
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "query" : {
|
|
|
"match" : { "user": "kimchy" }
|
|
"match" : { "user": "kimchy" }
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -95,10 +95,10 @@ Just for kicks, let's get all the documents stored (we should see the user as we
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|
curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|
|
-{
|
|
|
|
|
- "query" : {
|
|
|
|
|
- "matchAll" : {}
|
|
|
|
|
- }
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "query" : {
|
|
|
|
|
+ "matchAll" : {}
|
|
|
|
|
+ }
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -106,12 +106,12 @@ We can also do range search (the @postDate@ was automatically identified as date
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|
curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|
|
-{
|
|
|
|
|
- "query" : {
|
|
|
|
|
- "range" : {
|
|
|
|
|
- "postDate" : { "from" : "2009-11-15T13:00:00", "to" : "2009-11-15T14:00:00" }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "query" : {
|
|
|
|
|
+ "range" : {
|
|
|
|
|
+ "postDate" : { "from" : "2009-11-15T13:00:00", "to" : "2009-11-15T14:00:00" }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -129,17 +129,17 @@ Another way to define our simple twitter system is to have a different index per
|
|
|
curl -XPUT 'http://localhost:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
|
|
curl -XPUT 'http://localhost:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
|
|
|
|
|
|
|
|
curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
|
|
curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
|
|
|
-{
|
|
|
|
|
- "user": "kimchy",
|
|
|
|
|
- "postDate": "2009-11-15T13:12:00",
|
|
|
|
|
- "message": "Trying out Elasticsearch, so far so good?"
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "user": "kimchy",
|
|
|
|
|
+ "postDate": "2009-11-15T13:12:00",
|
|
|
|
|
+ "message": "Trying out Elasticsearch, so far so good?"
|
|
|
}'
|
|
}'
|
|
|
|
|
|
|
|
curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
|
|
curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
|
|
|
-{
|
|
|
|
|
- "user": "kimchy",
|
|
|
|
|
- "postDate": "2009-11-15T14:12:12",
|
|
|
|
|
- "message": "Another tweet, will it be indexed?"
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "user": "kimchy",
|
|
|
|
|
+ "postDate": "2009-11-15T14:12:12",
|
|
|
|
|
+ "message": "Another tweet, will it be indexed?"
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -149,11 +149,11 @@ Complete control on the index level is allowed. As an example, in the above case
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
curl -XPUT http://localhost:9200/another_user/ -d '
|
|
curl -XPUT http://localhost:9200/another_user/ -d '
|
|
|
-{
|
|
|
|
|
- "index" : {
|
|
|
|
|
- "numberOfShards" : 1,
|
|
|
|
|
- "numberOfReplicas" : 1
|
|
|
|
|
- }
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "index" : {
|
|
|
|
|
+ "numberOfShards" : 1,
|
|
|
|
|
+ "numberOfReplicas" : 1
|
|
|
|
|
+ }
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -162,10 +162,10 @@ index (twitter user), for example:
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
|
|
curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
|
|
|
-{
|
|
|
|
|
- "query" : {
|
|
|
|
|
- "matchAll" : {}
|
|
|
|
|
- }
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "query" : {
|
|
|
|
|
+ "matchAll" : {}
|
|
|
|
|
+ }
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -173,10 +173,10 @@ Or on all the indices:
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
|
|
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
|
|
|
-{
|
|
|
|
|
- "query" : {
|
|
|
|
|
- "matchAll" : {}
|
|
|
|
|
- }
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ "query" : {
|
|
|
|
|
+ "matchAll" : {}
|
|
|
|
|
+ }
|
|
|
}'
|
|
}'
|
|
|
</pre>
|
|
</pre>
|
|
|
|
|
|
|
@@ -213,7 +213,7 @@ In order to ensure a smooth upgrade process from earlier versions of Elasticsear
|
|
|
h1. License
|
|
h1. License
|
|
|
|
|
|
|
|
<pre>
|
|
<pre>
|
|
|
-This software is licensed under the Apache 2 license, quoted below.
|
|
|
|
|
|
|
+This software is licensed under the Apache License, version 2 ("ALv2"), quoted below.
|
|
|
|
|
|
|
|
Copyright 2009-2014 Elasticsearch <http://www.elasticsearch.org>
|
|
Copyright 2009-2014 Elasticsearch <http://www.elasticsearch.org>
|
|
|
|
|
|