update readme file
This commit is contained in:
parent
290ecd4c95
commit
54dc5a59b1
|
@ -46,21 +46,29 @@ h3. Indexing
|
||||||
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):
|
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):
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
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 Elastic Search, so far so good?" }'
|
{
|
||||||
|
"user": "kimchy",
|
||||||
|
"postDate": "2009-11-15T13:12:00",
|
||||||
|
"message": "Trying out Elastic Search, 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>
|
||||||
|
|
||||||
Now, lets see if the information was added by GETting it:
|
Now, lets see if the information was added by GETting it:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -X GET http://localhost:9200/twitter/user/kimchy?pretty=true
|
curl -XGET 'http://localhost:9200/twitter/user/kimchy?pretty=true'
|
||||||
curl -X GET http://localhost:9200/twitter/tweet/1?pretty=true
|
curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
|
||||||
curl -X GET http://localhost:9200/twitter/tweet/2?pretty=true
|
curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
h3. Searching
|
h3. Searching
|
||||||
|
@ -69,28 +77,42 @@ Mmm search..., shouldn't it be elastic?
|
||||||
Lets find all the tweets that @kimchy@ posted:
|
Lets find all the tweets that @kimchy@ posted:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET http://localhost:9200/twitter/tweet/_search?q=user:kimchy\&pretty=true
|
curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
We can also use the JSON query language ElasticSearch provides instead of a query string:
|
We can also use the JSON query language ElasticSearch provides instead of a query string:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XPOST http://localhost:9200/twitter/tweet/_search?pretty=true -d \
|
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
||||||
'{ query : { term : { user: "kimchy" } } }'
|
{
|
||||||
|
"query" : {
|
||||||
|
"term" : { "user": "kimchy" }
|
||||||
|
}
|
||||||
|
}'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Just for kicks, lets get all the documents stored (we should see the user as well):
|
Just for kicks, lets get all the documents stored (we should see the user as well):
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
We can also do range search (the @postDate@ was automatically identified as date)
|
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>
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
@ -104,13 +126,21 @@ ElasticSearch support multiple indices, as well as multiple types per index. In
|
||||||
Another way to define our simple twitter system is to have a different index per user. Here is the indexing curl's in this case:
|
Another way to define our simple twitter system is to have a different index per user. Here is the indexing curl's in this case:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
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 Elastic Search, so far so good?" }'
|
{
|
||||||
|
"user": "kimchy",
|
||||||
|
"postDate": "2009-11-15T13:12:00",
|
||||||
|
"message": "Trying out Elastic Search, 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>
|
||||||
|
|
||||||
The above index information into the @kimchy@ index, with two types, @info@ and @tweet@. Each user will get his own special index.
|
The above index information into the @kimchy@ index, with two types, @info@ and @tweet@. Each user will get his own special index.
|
||||||
|
@ -118,23 +148,36 @@ The above index information into the @kimchy@ index, with two types, @info@ and
|
||||||
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):
|
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):
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
Search (and similar operations) are multi index aware. This means that we can easily search on more than one
|
Search (and similar operations) are multi index aware. This means that we can easily search on more than one
|
||||||
index (twitter user), for example:
|
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>
|
||||||
|
|
||||||
Or on all the indices:
|
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>
|
||||||
|
|
||||||
{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).
|
{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).
|
||||||
|
@ -165,14 +208,14 @@ We have just covered a very small portion of what ElasticSearch is all about. Fo
|
||||||
|
|
||||||
h3. Building from Source
|
h3. Building from Source
|
||||||
|
|
||||||
ElasticSearch uses Gradle:http://www.gradle.org for its build system. In order to create a distribution, simply run @gradlew devRelease@, the distribution will be created under @build/distributions@.
|
ElasticSearch uses Gradle:http://www.gradle.org for its build system. In order to create a distribution, simply run @gradlew@, the distribution will be created under @build/distributions@.
|
||||||
|
|
||||||
h1. License
|
h1. License
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
This software is licensed under the Apache 2 license, quoted below.
|
This software is licensed under the Apache 2 license, quoted below.
|
||||||
|
|
||||||
Copyright 2009-2010 Elastic Search <http://www.elasticsearch.com>
|
Copyright 2009-2010 Shay Banon and ElasticSearch <http://www.elasticsearch.com>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
use this file except in compliance with the License. You may obtain a copy of
|
use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
|
Loading…
Reference in New Issue