3
3
` es ` is a small command line tool to interact with the
4
4
ElasticSearch search engine.
5
5
6
+ Notice that you could do all of this with ` curl ` commands, as
7
+ seen on the [ ElasticSearch API] ( http://www.elasticsearch.org/guide/reference/api/ ) .
8
+ However, you probably save a few keystrokes with ` es ` .
9
+
6
10
## Setup
7
11
8
12
You need to compile yourself currently:
@@ -14,7 +18,17 @@ You need to compile yourself currently:
14
18
15
19
## Commands
16
20
17
- Lets list indices.
21
+ Before we start, you can always lookup the ElasticSearch API via
22
+ the ` api ` command, like so:
23
+
24
+ $ es api indices
25
+
26
+ The ` api ` command will open up a browser window with the API page
27
+ that matches the specified command. You can find the complete
28
+ [ ElasticSearch API here] ( http://www.elasticsearch.org/guide/reference/api/ ) .
29
+
30
+ Let's get started. First we list existing indices, either all of them
31
+ or via a regular expression.
18
32
19
33
$ es indices
20
34
master
@@ -24,7 +38,9 @@ Lets list indices.
24
38
master
25
39
marvel
26
40
27
- And create a new index. This can be useful if you e.g. added templates.
41
+ Let's create a new index. Use the -f flag to force creation, i.e. it will
42
+ not print an error if the index already exists (and won't touch the
43
+ existing index).
28
44
29
45
$ es create twitter
30
46
$ es indices
@@ -36,7 +52,7 @@ And create a new index. This can be useful if you e.g. added templates.
36
52
Error: IndexAlreadyExistsException[[twitter] Already exists] (400)
37
53
$ es create -f twitter
38
54
39
- Now, lets delete indices.
55
+ Delete indices again .
40
56
41
57
$ es delete twitter
42
58
$ es indices
@@ -51,7 +67,7 @@ Now, lets delete indices.
51
67
marvel
52
68
dummy
53
69
54
- Let's review the mapping of an index .
70
+ Let's review mappings, and even create mappings from the command line .
55
71
56
72
$ es mapping dummy
57
73
{
@@ -60,6 +76,21 @@ Let's review the mapping of an index.
60
76
}
61
77
$ es mapping nonexistent
62
78
Error: IndexMissingException[[nonexistent] missing] (404)
79
+ $ es create twitter
80
+ $ es put-mapping twitter tweet < tweet-mapping.json
81
+ $ es mapping twitter
82
+ {
83
+ "twitter" : {
84
+ "tweet" : {
85
+ "properties" : {
86
+ "message" : {
87
+ "type" : "string",
88
+ "store" : "yes"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
63
94
64
95
Templates, oh how I love thee... here's a sample session.
65
96
0 commit comments