Skip to content

Commit 4e27edd

Browse files
authored
Make the README use a single type in examples. (#26098)
It currently indexes both users and tweets as their own types. Closes #25978
1 parent 0e54603 commit 4e27edd

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

README.textile

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ Elasticsearch is a distributed RESTful search engine built for the cloud. Featur
1010
** Each index is fully sharded with a configurable number of shards.
1111
** Each shard can have one or more replicas.
1212
** Read / Search operations performed on any of the replica shards.
13-
* Multi Tenant with Multi Types.
13+
* Multi Tenant.
1414
** Support for more than one index.
15-
** Support for more than one type per index.
1615
** Index level configuration (number of shards, index storage, ...).
1716
* Various set of APIs
1817
** HTTP RESTful API
1918
** Native Java API.
2019
** All APIs perform automatic node operation rerouting.
2120
* Document oriented
2221
** No need for upfront schema definition.
23-
** Schema can be defined per type for customization of the indexing process.
22+
** Schema can be defined for customization of the indexing process.
2423
* Reliable, Asynchronous Write Behind for long term persistency.
2524
* (Near) Real Time Search.
2625
* Built on top of Lucene
@@ -47,32 +46,37 @@ h3. Installation
4746

4847
h3. Indexing
4948

50-
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):
49+
Let's try and index some twitter like information. First, let's index some tweets (the @twitter@ index will be created automatically):
5150

5251
<pre>
53-
curl -XPUT 'http://localhost:9200/twitter/user/kimchy?pretty' -H 'Content-Type: application/json' -d '{ "name" : "Shay Banon" }'
54-
55-
curl -XPUT 'http://localhost:9200/twitter/tweet/1?pretty' -H 'Content-Type: application/json' -d '
52+
curl -XPUT 'http://localhost:9200/twitter/doc/1?pretty' -H 'Content-Type: application/json' -d '
5653
{
5754
"user": "kimchy",
5855
"post_date": "2009-11-15T13:12:00",
5956
"message": "Trying out Elasticsearch, so far so good?"
6057
}'
6158

62-
curl -XPUT 'http://localhost:9200/twitter/tweet/2?pretty' -H 'Content-Type: application/json' -d '
59+
curl -XPUT 'http://localhost:9200/twitter/doc/2?pretty' -H 'Content-Type: application/json' -d '
6360
{
6461
"user": "kimchy",
6562
"post_date": "2009-11-15T14:12:12",
6663
"message": "Another tweet, will it be indexed?"
6764
}'
65+
66+
curl -XPUT 'http://localhost:9200/twitter/doc/3?pretty' -H 'Content-Type: application/json' -d '
67+
{
68+
"user": "elastic",
69+
"post_date": "2010-01-15T01:46:38",
70+
"message": "Building the site, should be kewl"
71+
}'
6872
</pre>
6973

7074
Now, let's see if the information was added by GETting it:
7175

7276
<pre>
73-
curl -XGET 'http://localhost:9200/twitter/user/kimchy?pretty=true'
74-
curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
75-
curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
77+
curl -XGET 'http://localhost:9200/twitter/doc/1?pretty=true'
78+
curl -XGET 'http://localhost:9200/twitter/doc/2?pretty=true'
79+
curl -XGET 'http://localhost:9200/twitter/doc/3?pretty=true'
7680
</pre>
7781

7882
h3. Searching
@@ -81,21 +85,21 @@ Mmm search..., shouldn't it be elastic?
8185
Let's find all the tweets that @kimchy@ posted:
8286

8387
<pre>
84-
curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=true'
88+
curl -XGET 'http://localhost:9200/twitter/_search?q=user:kimchy&pretty=true'
8589
</pre>
8690

8791
We can also use the JSON query language Elasticsearch provides instead of a query string:
8892

8993
<pre>
90-
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty=true' -H 'Content-Type: application/json' -d '
94+
curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -H 'Content-Type: application/json' -d '
9195
{
9296
"query" : {
9397
"match" : { "user": "kimchy" }
9498
}
9599
}'
96100
</pre>
97101

98-
Just for kicks, let's get all the documents stored (we should see the user as well):
102+
Just for kicks, let's get all the documents stored (we should see the tweet from @elastic@ as well):
99103

100104
<pre>
101105
curl -XGET 'http://localhost:9200/twitter/_search?pretty=true' -H 'Content-Type: application/json' -d '
@@ -125,29 +129,27 @@ h3. Multi Tenant - Indices and Types
125129

126130
Man, 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.
127131

128-
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@.
132+
Elasticsearch supports multiple indices. In the previous example we used an index called @twitter@ that stored tweets for every user.
129133

130134
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:
131135

132136
<pre>
133-
curl -XPUT 'http://localhost:9200/kimchy/info/1?pretty' -H 'Content-Type: application/json' -d '{ "name" : "Shay Banon" }'
134-
135-
curl -XPUT 'http://localhost:9200/kimchy/tweet/1?pretty' -H 'Content-Type: application/json' -d '
137+
curl -XPUT 'http://localhost:9200/kimchy/doc/1?pretty' -H 'Content-Type: application/json' -d '
136138
{
137139
"user": "kimchy",
138140
"post_date": "2009-11-15T13:12:00",
139141
"message": "Trying out Elasticsearch, so far so good?"
140142
}'
141143

142-
curl -XPUT 'http://localhost:9200/kimchy/tweet/2?pretty' -H 'Content-Type: application/json' -d '
144+
curl -XPUT 'http://localhost:9200/kimchy/doc/2?pretty' -H 'Content-Type: application/json' -d '
143145
{
144146
"user": "kimchy",
145147
"post_date": "2009-11-15T14:12:12",
146148
"message": "Another tweet, will it be indexed?"
147149
}'
148150
</pre>
149151

150-
The above will index information into the @kimchy@ index, with two types, @info@ and @tweet@. Each user will get their own special index.
152+
The above will index information into the @kimchy@ index. Each user will get their own special index.
151153

152154
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):
153155

0 commit comments

Comments
 (0)