-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.txt
398 lines (304 loc) · 13.8 KB
/
commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
// instulations
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
sudo apt-get install default-jdk
// conmands
sudo systemctl start elasticsearch
curl 'localhost:9200/?pretty'
sudo systemctl stop elasticsearch
sudo systemctl start elasticsearch
https://github.com/StephaneBour/sense-chrome
composer create-project --prefer-dist laravel/laravel Elasticsearch-Course "5.5.*"
composer require elasticsearch/elasticsearch
composer require ruflin/Elastica
composer require laravel/scout
php artisan vendor:publish
http://elasticsearch.local
curl http://elasticsearch.local:9200/?pretty
curl http://elasticsearch.local:9200/_cat/indices?v
curl -XPUT http://elasticsearch.local:9200/pets/dog/1/?pretty -d '{"name": "Susana","age":2,"gender":"female","color":"brown","goodDog":true,"home town":"Nogal, Massachusetts","about":"Ad laboris occaecat ut elit. Sit consequant velit sit est reprehenderit aliquip magna amet dolore incididunt ad. Mollit eiusmod ex consequat cillum anim exercitation fugiat ipsum consectetur ut dolor. Exercitation minim tempor cillum commodo ad amet ea. Nostrud irure occaecat exercitation ut nisi excepteur.\r\n","registered":"2013-06-11"}'
https://discuss.elastic.co/t/x-www-urlencoded-not-supported/108128
https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests
curl -H'Content-Type: application/json' -XPUT http://elasticsearch.local:9200/pets/dog/1/?pretty -d '{"name": "Susana","age":2,"gender":"female","color":"brown","goodDog":true,"home town":"Nogal, Massachusetts","about":"Ad laboris occaecat ut elit. Sit consequant velit sit est reprehenderit aliquip magna amet dolore incididunt ad. Mollit eiusmod ex consequat cillum anim exercitation fugiat ipsum consectetur ut dolor. Exercitation minim tempor cillum commodo ad amet ea. Nostrud irure occaecat exercitation ut nisi excepteur.\r\n","registered":"2013-06-11"}'
curl http://elasticsearch.local:9200/pets/_mapping/dog/?pretty | less
curl 'http://elasticsearch.local:9200/pets/dog/_search?q=name:susana&pretty'
curl -s -XPOST -H "Content-Type: application/x-ndjson" http://elasticsearch.local:9200/_bulk?pretty -d'
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "10" } }
{ "name" : "Benjamin", "age" : "10","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets","_type" : "dog","_id" : "11" } }
{ "name" : "Jackson", "age" : "11","gender" : "male","color" : "black","goodDog" : true,"home town" : "Lydia,Maine","about" : "Ea cupidatat magna ea nostrud nostrud sunt incididunt eu excepteur ex. Est Lorem dolore partiatur mollit nulla. Magna elit consequant culpa ex velit et fugiat proident ea ipsum ut laborum cillum. Anim ipsum excepteur incididuntamet commodo magna magna voluptate Lorem. Qui proident duis occaecat ad consequat officia cillum est aliquip consequat ex. Ullamco qui dolor do do ex.\r\n","registered" : "2010-04-26" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "12" } }
{ "name" : "Benjamin", "age" : "1","gender" : "male","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "13" } }
{ "name" : "Benjamin", "age" : "88","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "14" } }
{ "name" : "Benjamin", "age" : "60","gender" : "male","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "15" } }
{ "name" : "Benjamin", "age" : "40","gender" : "male","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "16" } }
{ "name" : "Benjamin", "age" : "40","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "17" } }
{ "name" : "Benjamin", "age" : "33","gender" : "male","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "18" } }
{ "name" : "Benjamin", "age" : "88","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "19" } }
{ "name" : "Benjamin", "age" : "19","gender" : "male","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmo/pets/dog/1/d et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "20" } }
{ "name" : "Benjamin", "age" : "25","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "21" } }
{ "name" : "test2", "age" : "88","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2018-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "22" } }
{ "name" : "Benjamin", "age" : "88","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2014-11-18" }
{ "index" : { "_index" : "pets", "_type" : "dog","_id" : "23" } }
{ "name" : "test1", "age" : "88","gender" : "female","color" : "black","goodDog" : true,"home town" : "Naomi,America Samoa","about" : "Nostrud eu mollit veniam est nulla ullamco. Magna aute enim officia quis ad in duis ad in duis partiatur. Inproident eiusmod et excepteur quis in voluptate qui culpa sint dolore. Ad eu sint fugiat deserunt proident minim. Deserunt ea commodo dolor anim sunt deserunt. \r\n","registered" : "2016-11-18" }
' | less
// Important : insert data object must be in one line no spaces allowed
curl -s 'http://elasticsearch.local:9200/pets/dog/_search?q=about:Nostrud&pretty' | less
curl -s 'http://elasticsearch.local:9200/pets/dog/_count?q=about:Nostrud&pretty'
query DSL from browser
GET _search
{
"query":
{
"match_all": {}
}
}
Get /
POST /pets/dog/_search
POST /pets/dog/_search
{
"query":
{
"match":
{
"about": "ipsum"
}
}
}
POST /pets/dog/_search
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
]
}
}
}
POST /pets/dog/_search
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
],
"should":
[
{
"term": {"goodDog": true}
},
{
"term": {"gender": "male"}
}
]
}
}
}
POST /pets/dog/_search?explain
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
],
"should":
[
{
"term": {"goodDog": true}
},
{
"term": {"gender": "male"}
}
]
}
}
}
POST /pets/dog/_search
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
],
"filter":
[
{
"range":
{
"registered":
{
"gte": "2015-01-01"
}
}
}
]
}
}
}
http://elasticsearch.local/elasticsearch/test
http://elasticsearch.local/elastica/test
http://elasticsearch.local/elasticsearch/data
// delete index
curl -XDELETE http://elasticsearch.local:9200/pets
// create index
in browser in extension
PUT pets
or in terminal
curl -X PUT "localhost:9200/pets"
http://elasticsearch.local/elasticsearch/data
GET _search
{
"query":
{
"match_all": {}
}
}
Get /
POST /pets/dog/_search
POST /pets/dog/_search
{
"query":
{
"match":
{
"about": "ipsum"
}
}
}
POST /pets/dog/_search
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
]
}
}
}
POST /pets/dog/_search
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
],
"should":
[
{
"term": {"goodDog": true}
},
{
"term": {"gender": "male"}
}
]
}
}
}
POST /pets/dog/_search?explain
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
],
"should":
[
{
"term": {"goodDog": true}
},
{
"term": {"gender": "male"}
}
]
}
}
}
POST /pets/dog/_search
{
"query":
{
"bool":
{
"must":
[
{
"match": { "about": "ipsum" }
}
],
"filter":
[
{
"range":
{
"registered":
{
"gte": "2015-01-01"
}
}
}
]
}
}
}
GET /pets/bird/_search
{
"query":
{
"match_all": {}
}
}
// in browser in extension
GET /pets/cat/_search
{
"query":
{
"match_all": {}
}
}
// so we have two clients :
1- elasticsearch php client.
2- elastica client.