mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-31 20:38:40 +00:00
[DOC] Use 127.0.0.1 instead of localhost in READMEs
Users with IPv6 preferred over IPv4 may have `localhost` resolve to `::1` instead of `127.0.0.1`, so we should be explicit so they don't run into issues.
This commit is contained in:
parent
942d040f45
commit
6f5a25d98e
@ -42,7 +42,7 @@ h3. Installation
|
|||||||
|
|
||||||
* "Download":https://www.elastic.co/downloads/elasticsearch and unzip the Elasticsearch official distribution.
|
* "Download":https://www.elastic.co/downloads/elasticsearch and unzip the Elasticsearch official distribution.
|
||||||
* Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
|
* Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
|
||||||
* Run @curl -X GET http://localhost:9200/@.
|
* Run @curl -X GET http://127.0.0.1:9200/@.
|
||||||
* Start more servers ...
|
* Start more servers ...
|
||||||
|
|
||||||
h3. Indexing
|
h3. Indexing
|
||||||
@ -50,16 +50,16 @@ h3. Indexing
|
|||||||
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):
|
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):
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
curl -XPUT 'http://127.0.0.1:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
|
curl -XPUT 'http://127.0.0.1:9200/twitter/tweet/1' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T13:12:00",
|
"postDate": "2009-11-15T13:12:00",
|
||||||
"message": "Trying out Elasticsearch, so far so good?"
|
"message": "Trying out Elasticsearch, so far so good?"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
curl -XPUT 'http://127.0.0.1:9200/twitter/tweet/2' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T14:12:12",
|
"postDate": "2009-11-15T14:12:12",
|
||||||
@ -70,9 +70,9 @@ curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
|||||||
Now, let's see if the information was added by GETting it:
|
Now, let's see if the information was added by GETting it:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET 'http://localhost:9200/twitter/user/kimchy?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/user/kimchy?pretty=true'
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/1?pretty=true'
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/2?pretty=true'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
h3. Searching
|
h3. Searching
|
||||||
@ -81,13 +81,13 @@ 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>
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
|
curl -XGET 'http://127.0.0.1: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 -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"match" : { "user": "kimchy" }
|
"match" : { "user": "kimchy" }
|
||||||
@ -98,7 +98,7 @@ curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
|||||||
Just for kicks, let's get all the documents stored (we should see the user as well):
|
Just for kicks, let's 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://127.0.0.1:9200/twitter/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
@ -109,7 +109,7 @@ curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|||||||
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://127.0.0.1:9200/twitter/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"range" : {
|
"range" : {
|
||||||
@ -130,16 +130,16 @@ Elasticsearch supports 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 (note, though that each index has an overhead). 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 (note, though that each index has an overhead). 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://127.0.0.1:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
|
curl -XPUT 'http://127.0.0.1:9200/kimchy/tweet/1' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T13:12:00",
|
"postDate": "2009-11-15T13:12:00",
|
||||||
"message": "Trying out Elasticsearch, so far so good?"
|
"message": "Trying out Elasticsearch, so far so good?"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
|
curl -XPUT 'http://127.0.0.1:9200/kimchy/tweet/2' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T14:12:12",
|
"postDate": "2009-11-15T14:12:12",
|
||||||
@ -152,7 +152,7 @@ The above will index information into the @kimchy@ index, with two types, @info@
|
|||||||
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://127.0.0.1:9200/another_user/ -d '
|
||||||
{
|
{
|
||||||
"index" : {
|
"index" : {
|
||||||
"numberOfShards" : 1,
|
"numberOfShards" : 1,
|
||||||
@ -165,7 +165,7 @@ Search (and similar operations) are multi index aware. This means that we can ea
|
|||||||
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://127.0.0.1:9200/kimchy,another_user/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
@ -176,7 +176,7 @@ curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
|
|||||||
Or on all the indices:
|
Or on all the indices:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
|
curl -XGET 'http://127.0.0.1:9200/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
|
@ -42,7 +42,7 @@ h3. Installation
|
|||||||
|
|
||||||
* "Download":https://www.elastic.co/downloads/elasticsearch and unzip the Elasticsearch official distribution.
|
* "Download":https://www.elastic.co/downloads/elasticsearch and unzip the Elasticsearch official distribution.
|
||||||
* Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
|
* Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
|
||||||
* Run @curl -X GET http://localhost:9200/@.
|
* Run @curl -X GET http://127.0.0.1:9200/@.
|
||||||
* Start more servers ...
|
* Start more servers ...
|
||||||
|
|
||||||
h3. Indexing
|
h3. Indexing
|
||||||
@ -50,16 +50,16 @@ h3. Indexing
|
|||||||
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):
|
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):
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
curl -XPUT 'http://127.0.0.1:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
|
curl -XPUT 'http://127.0.0.1:9200/twitter/tweet/1' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T13:12:00",
|
"postDate": "2009-11-15T13:12:00",
|
||||||
"message": "Trying out Elasticsearch, so far so good?"
|
"message": "Trying out Elasticsearch, so far so good?"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
curl -XPUT 'http://127.0.0.1:9200/twitter/tweet/2' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T14:12:12",
|
"postDate": "2009-11-15T14:12:12",
|
||||||
@ -70,9 +70,9 @@ curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
|||||||
Now, let's see if the information was added by GETting it:
|
Now, let's see if the information was added by GETting it:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET 'http://localhost:9200/twitter/user/kimchy?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/user/kimchy?pretty=true'
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/1?pretty=true'
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/2?pretty=true'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
h3. Searching
|
h3. Searching
|
||||||
@ -81,13 +81,13 @@ 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>
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
|
curl -XGET 'http://127.0.0.1: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 -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"match" : { "user": "kimchy" }
|
"match" : { "user": "kimchy" }
|
||||||
@ -98,7 +98,7 @@ curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
|||||||
Just for kicks, let's get all the documents stored (we should see the user as well):
|
Just for kicks, let's 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://127.0.0.1:9200/twitter/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
@ -109,7 +109,7 @@ curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|||||||
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://127.0.0.1:9200/twitter/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"range" : {
|
"range" : {
|
||||||
@ -130,16 +130,16 @@ Elasticsearch supports 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 (note, though that each index has an overhead). 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 (note, though that each index has an overhead). 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://127.0.0.1:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
|
curl -XPUT 'http://127.0.0.1:9200/kimchy/tweet/1' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T13:12:00",
|
"postDate": "2009-11-15T13:12:00",
|
||||||
"message": "Trying out Elasticsearch, so far so good?"
|
"message": "Trying out Elasticsearch, so far so good?"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
|
curl -XPUT 'http://127.0.0.1:9200/kimchy/tweet/2' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T14:12:12",
|
"postDate": "2009-11-15T14:12:12",
|
||||||
@ -152,7 +152,7 @@ The above will index information into the @kimchy@ index, with two types, @info@
|
|||||||
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://127.0.0.1:9200/another_user/ -d '
|
||||||
{
|
{
|
||||||
"index" : {
|
"index" : {
|
||||||
"numberOfShards" : 1,
|
"numberOfShards" : 1,
|
||||||
@ -165,7 +165,7 @@ Search (and similar operations) are multi index aware. This means that we can ea
|
|||||||
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://127.0.0.1:9200/kimchy,another_user/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
@ -176,7 +176,7 @@ curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
|
|||||||
Or on all the indices:
|
Or on all the indices:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
|
curl -XGET 'http://127.0.0.1:9200/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
|
@ -42,7 +42,7 @@ h3. Installation
|
|||||||
|
|
||||||
* "Download":https://www.elastic.co/downloads/elasticsearch and unzip the Elasticsearch official distribution.
|
* "Download":https://www.elastic.co/downloads/elasticsearch and unzip the Elasticsearch official distribution.
|
||||||
* Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
|
* Run @bin/elasticsearch@ on unix, or @bin\elasticsearch.bat@ on windows.
|
||||||
* Run @curl -X GET http://localhost:9200/@.
|
* Run @curl -X GET http://127.0.0.1:9200/@.
|
||||||
* Start more servers ...
|
* Start more servers ...
|
||||||
|
|
||||||
h3. Indexing
|
h3. Indexing
|
||||||
@ -50,16 +50,16 @@ h3. Indexing
|
|||||||
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):
|
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):
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
curl -XPUT 'http://127.0.0.1:9200/twitter/user/kimchy' -d '{ "name" : "Shay Banon" }'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '
|
curl -XPUT 'http://127.0.0.1:9200/twitter/tweet/1' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T13:12:00",
|
"postDate": "2009-11-15T13:12:00",
|
||||||
"message": "Trying out Elasticsearch, so far so good?"
|
"message": "Trying out Elasticsearch, so far so good?"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
curl -XPUT 'http://127.0.0.1:9200/twitter/tweet/2' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T14:12:12",
|
"postDate": "2009-11-15T14:12:12",
|
||||||
@ -70,9 +70,9 @@ curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d '
|
|||||||
Now, let's see if the information was added by GETting it:
|
Now, let's see if the information was added by GETting it:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET 'http://localhost:9200/twitter/user/kimchy?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/user/kimchy?pretty=true'
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/1?pretty=true'
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/2?pretty=true'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
h3. Searching
|
h3. Searching
|
||||||
@ -81,13 +81,13 @@ 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>
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
|
curl -XGET 'http://127.0.0.1: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 -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
curl -XGET 'http://127.0.0.1:9200/twitter/tweet/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"match" : { "user": "kimchy" }
|
"match" : { "user": "kimchy" }
|
||||||
@ -98,7 +98,7 @@ curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -d '
|
|||||||
Just for kicks, let's get all the documents stored (we should see the user as well):
|
Just for kicks, let's 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://127.0.0.1:9200/twitter/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
@ -109,7 +109,7 @@ curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -d '
|
|||||||
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://127.0.0.1:9200/twitter/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"range" : {
|
"range" : {
|
||||||
@ -130,16 +130,16 @@ Elasticsearch supports 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 (note, though that each index has an overhead). 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 (note, though that each index has an overhead). 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://127.0.0.1:9200/kimchy/info/1' -d '{ "name" : "Shay Banon" }'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/kimchy/tweet/1' -d '
|
curl -XPUT 'http://127.0.0.1:9200/kimchy/tweet/1' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T13:12:00",
|
"postDate": "2009-11-15T13:12:00",
|
||||||
"message": "Trying out Elasticsearch, so far so good?"
|
"message": "Trying out Elasticsearch, so far so good?"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/kimchy/tweet/2' -d '
|
curl -XPUT 'http://127.0.0.1:9200/kimchy/tweet/2' -d '
|
||||||
{
|
{
|
||||||
"user": "kimchy",
|
"user": "kimchy",
|
||||||
"postDate": "2009-11-15T14:12:12",
|
"postDate": "2009-11-15T14:12:12",
|
||||||
@ -152,7 +152,7 @@ The above will index information into the @kimchy@ index, with two types, @info@
|
|||||||
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://127.0.0.1:9200/another_user/ -d '
|
||||||
{
|
{
|
||||||
"index" : {
|
"index" : {
|
||||||
"numberOfShards" : 1,
|
"numberOfShards" : 1,
|
||||||
@ -165,7 +165,7 @@ Search (and similar operations) are multi index aware. This means that we can ea
|
|||||||
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://127.0.0.1:9200/kimchy,another_user/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
@ -176,7 +176,7 @@ curl -XGET 'http://localhost:9200/kimchy,another_user/_search?pretty=true' -d '
|
|||||||
Or on all the indices:
|
Or on all the indices:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
|
curl -XGET 'http://127.0.0.1:9200/_search?pretty=true' -d '
|
||||||
{
|
{
|
||||||
"query" : {
|
"query" : {
|
||||||
"matchAll" : {}
|
"matchAll" : {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user