-
Notifications
You must be signed in to change notification settings - Fork 165
/
populate.sh
executable file
·460 lines (417 loc) · 12.9 KB
/
populate.sh
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
#!/usr/bin/env bash
ADDRESS=$1
if [ -z $ADDRESS ]; then
ADDRESS="localhost:9200"
fi
# Check that Elasticsearch is running
curl -s "http://$ADDRESS" 2>&1 > /dev/null
if [ $? != 0 ]; then
echo "Unable to contact Elasticsearch at $ADDRESS"
echo "Please ensure Elasticsearch is running and can be reached at http://$ADDRESS/"
exit -1
fi
echo "WARNING, this script will delete the 'get-together' and the 'myindex' indices and re-index all data!"
echo "Press Control-C to cancel this operation."
echo
echo "Press [Enter] to continue."
read
# Delete the old index, swallow failures if it doesn't exist
curl -s -XDELETE "$ADDRESS/get-together" > /dev/null
# Create the next index using mapping.json
echo "Creating 'get-together' index..."
curl -s -XPOST "$ADDRESS/get-together" -d@$(dirname $0)/mapping.json
# Wait for index to become yellow
curl -s "$ADDRESS/get-together/_health?wait_for_status=yellow&timeout=10s" > /dev/null
echo
echo "Done creating 'get-together' index."
echo
echo "Indexing data..."
echo "Indexing groups..."
curl -s -XPOST "$ADDRESS/get-together/group/1" -d'{
"name": "Denver Clojure",
"organizer": ["Daniel", "Lee"],
"description": "Group of Clojure enthusiasts from Denver who want to hack on code together and learn more about Clojure",
"created_on": "2012-06-15",
"tags": ["clojure", "denver", "functional programming", "jvm", "java"],
"members": ["Lee", "Daniel", "Mike"],
"location_group": "Denver, Colorado, USA"
}'
echo
curl -s -XPOST "$ADDRESS/get-together/group/2" -d'{
"name": "Elasticsearch Denver",
"organizer": "Lee",
"description": "Get together to learn more about using Elasticsearch, the applications and neat things you can do with ES!",
"created_on": "2013-03-15",
"tags": ["denver", "elasticsearch", "big data", "lucene", "solr"],
"members": ["Lee", "Mike"],
"location_group": "Denver, Colorado, USA"
}'
echo
curl -s -XPOST "$ADDRESS/get-together/group/3" -d'{
"name": "Elasticsearch San Francisco",
"organizer": "Mik",
"description": "Elasticsearch group for ES users of all knowledge levels",
"created_on": "2012-08-07",
"tags": ["elasticsearch", "big data", "lucene", "open source"],
"members": ["Lee", "Igor"],
"location_group": "San Francisco, California, USA"
}'
echo
curl -s -XPOST "$ADDRESS/get-together/group/4" -d'{
"name": "Boulder/Denver big data get-together",
"organizer": "Andy",
"description": "Come learn and share your experience with nosql & big data technologies, no experience required",
"created_on": "2010-04-02",
"tags": ["big data", "data visualization", "open source", "cloud computing", "hadoop"],
"members": ["Greg", "Bill"],
"location_group": "Boulder, Colorado, USA"
}'
echo
curl -s -XPOST "$ADDRESS/get-together/group/5" -d'{
"name": "Enterprise search London get-together",
"organizer": "Tyler",
"description": "Enterprise search get-togethers are an opportunity to get together with other people doing search.",
"created_on": "2009-11-25",
"tags": ["enterprise search", "apache lucene", "solr", "open source", "text analytics"],
"members": ["Clint", "James"],
"location_group": "London, England, UK"
}'
echo
echo "Done indexing groups."
echo "Indexing events..."
curl -s -XPOST "$ADDRESS/get-together/event/100?parent=1" -d'{
"host": ["Lee", "Troy"],
"title": "Liberator and Immutant",
"description": "We will discuss two different frameworks in Clojure for doing different things. Liberator is a ring-compatible web framework based on Erlang Webmachine. Immutant is an all-in-one enterprise application based on JBoss.",
"attendees": ["Lee", "Troy", "Daniel", "Tom"],
"date": "2013-09-05T18:00",
"location_event": {
"name": "Stoneys Full Steam Tavern",
"geolocation": "39.752337,-105.00083"
},
"reviews": 4
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/101?parent=1" -d'{
"host": "Sean",
"title": "Sunday, Surly Sunday",
"description": "Sort out any setup issues and work on Surlybird issues. We can use the EC2 node as a bounce point for pairing.",
"attendees": ["Daniel", "Michael", "Sean"],
"date": "2013-07-21T18:30",
"location_event": {
"name": "IRC, #denofclojure"
},
"reviews": 2
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/102?parent=1" -d'{
"host": "Daniel",
"title": "10 Clojure coding techniques you should know, and project openbike",
"description": "What are ten Clojure coding techniques that you wish everyone knew? We will also check on the status of Project Openbike.",
"attendees": ["Lee", "Tyler", "Daniel", "Stuart", "Lance"],
"date": "2013-07-11T18:00",
"location_event": {
"name": "Stoneys Full Steam Tavern",
"geolocation": "39.752337,-105.00083"
},
"reviews": 3
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/103?parent=2" -d'{
"host": "Lee",
"title": "Introduction to Elasticsearch",
"description": "An introduction to ES and each other. We can meet and greet and I will present on some Elasticsearch basics and how we use it.",
"attendees": ["Lee", "Martin", "Greg", "Mike"],
"date": "2013-04-17T19:00",
"location_event": {
"name": "Stoneys Full Steam Tavern",
"geolocation": "39.752337,-105.00083"
},
"reviews": 5
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/104?parent=2" -d'{
"host": "Lee",
"title": "Queries and Filters",
"description": "A get together to talk about different ways to query Elasticsearch, what works best for different kinds of applications.",
"attendees": ["Lee", "Greg", "Richard"],
"date": "2013-06-17T18:00",
"location_event": {
"name": "Stoneys Full Steam Tavern",
"geolocation": "39.752337,-105.00083"
},
"reviews": 1
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/105?parent=2" -d'{
"host": "Lee",
"title": "Elasticsearch and Logstash",
"description": "We can get together and talk about Logstash - http://logstash.net with a sneak peek at Kibana",
"attendees": ["Lee", "Greg", "Mike", "Delilah"],
"date": "2013-07-17T18:30",
"location_event": {
"name": "Stoneys Full Steam Tavern",
"geolocation": "39.752337,-105.00083"
},
"reviews": null
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/106?parent=3" -d'{
"host": "Mik",
"title": "Social management and monitoring tools",
"description": "Shay Banon will be there to answer questions and we can talk about management tools.",
"attendees": ["Shay", "Mik", "John", "Chris"],
"date": "2013-03-06T18:00",
"location_event": {
"name": "Quid Inc",
"geolocation": "37.798442,-122.399801"
},
"reviews": 5
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/107?parent=3" -d'{
"host": "Mik",
"title": "Logging and Elasticsearch",
"description": "Get a deep dive for what Elasticsearch is and how it can be used for logging with Logstash as well as Kibana!",
"attendees": ["Shay", "Rashid", "Erik", "Grant", "Mik"],
"date": "2013-04-08T18:00",
"location_event": {
"name": "Salesforce headquarters",
"geolocation": "37.793592,-122.397033"
},
"reviews": 3
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/108?parent=3" -d'{
"host": "Elyse",
"title": "Piggyback on Elasticsearch training in San Francisco",
"description": "We can piggyback on training by Elasticsearch to have some Q&A time with the ES devs",
"attendees": ["Shay", "Igor", "Uri", "Elyse"],
"date": "2013-05-23T19:00",
"location_event": {
"name": "NoSQL Roadshow",
"geolocation": "37.787742,-122.398964"
},
"reviews": 5
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/109?parent=4" -d'{
"host": "Andy",
"title": "Hortonworks, the future of Hadoop and big data",
"description": "Presentation on the work that hortonworks is doing on Hadoop",
"attendees": ["Andy", "Simon", "David", "Sam"],
"date": "2013-06-19T18:00",
"location_event": {
"name": "SendGrid Denver office",
"geolocation": "39.748477,-104.998852"
},
"reviews": 2
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/110?parent=4" -d'{
"host": "Andy",
"title": "Big Data and the cloud at Microsoft",
"description": "Discussion about the Microsoft Azure cloud and HDInsight.",
"attendees": ["Andy", "Michael", "Ben", "David"],
"date": "2013-07-31T18:00",
"location_event": {
"name": "Bing Boulder office",
"geolocation": "40.018528,-105.275806"
},
"reviews": 1
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/111?parent=4" -d'{
"host": "Andy",
"title": "Moving Hadoop to the mainstream",
"description": "Come hear about how Hadoop is moving to the main stream",
"attendees": ["Andy", "Matt", "Bill"],
"date": "2013-07-21T18:00",
"location_event": {
"name": "Courtyard Boulder Louisville",
"geolocation": "39.959409,-105.163497"
},
"reviews": 4
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/112?parent=5" -d'{
"host": "Dave Nolan",
"title": "real-time Elasticsearch",
"description": "We will discuss using Elasticsearch to index data in real time",
"attendees": ["Dave", "Shay", "John", "Harry"],
"date": "2013-02-18T18:30",
"location_event": {
"name": "SkillsMatter Exchange",
"geolocation": "51.524806,-0.099095"
},
"reviews": 3
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/113?parent=5" -d'{
"host": "Dave",
"title": "Elasticsearch at Rangespan and Exonar",
"description": "Representatives from Rangespan and Exonar will come and discuss how they use Elasticsearch",
"attendees": ["Dave", "Andrew", "David", "Clint"],
"date": "2013-06-24T18:30",
"location_event": {
"name": "Alumni Theatre",
"geolocation": "51.51558,-0.117699"
},
"reviews": 3
}'
echo
curl -s -XPOST "$ADDRESS/get-together/event/114?parent=5" -d'{
"host": "Yann",
"title": "Using Hadoop with Elasticsearch",
"description": "We will walk through using Hadoop with Elasticsearch for big data crunching!",
"attendees": ["Yann", "Bill", "James"],
"date": "2013-09-09T18:30",
"location_event": {
"name": "SkillsMatter Exchange",
"geolocation": "51.524806,-0.099095"
},
"reviews": 2
}'
echo
echo "Done indexing events."
# Refresh so data is available
curl -s -XPOST "$ADDRESS/get-together/_refresh"
echo
echo "Done indexing data."
echo
echo
echo "Creating Templates."
curl -s -XPUT "http://$ADDRESS/_template/logging_index_all" -d'{
"template" : "logstash-09-*",
"order" : 1,
"settings" : {
"number_of_shards" : 2,
"number_of_replicas" : 1
},
"mappings" : {
"date" : { "store": false }
},
"alias" : { "november" : {} }
}'
echo
curl -s -XPUT "http://$ADDRESS/_template/logging_index" -d '{
"template" : "logstash-*",
"order" : 0,
"settings" : {
"number_of_shards" : 2,
"number_of_replicas" : 1
},
"mappings" : {
"date" : { "store": true }
}
}'
echo
echo "Done Creating Templates."
echo
echo "Adding Dynamic Mapping"
curl -s -XDELETE "http://$ADDRESS/myindex" > /dev/null
curl -s -XPUT "http://$ADDRESS/myindex" -d'
{
"mappings" : {
"my_type" : {
"dynamic_templates" : [{
"UUID" : {
"match" : "*_guid",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}]
}
}
}'
echo
echo "Done Adding Dynamic Mapping"
echo
echo "Adding Aliases"
curl -s -XDELETE "http://$ADDRESS/november_2014_invoices" > /dev/null
curl -s -XDELETE "http://$ADDRESS/december_2014_invoices" > /dev/null
curl -s -XPOST "http://$ADDRESS/november_2014_invoices" -d'{}'
echo
curl -s -XPOST "http://$ADDRESS/december_2014_invoices" -d'
{
"mappings" :
{
"invoice" :
{
"properties" :
{
"revenue" : { "type" : "integer" }
}
}
}
}'
echo
curl -s -XPOST "http://$ADDRESS/_aliases" -d'
{
"actions" : [
{
"add" :
{
"index" : "november_2014_invoices",
"alias" : "2014_invoices"
},
"add" :
{
"index" : "december_2014_invoices",
"alias" : "2014_invoices"
},
"remove" :
{
"index" : "myindex",
"alias" : "december_2014_invoices"
}
}
]
}'
echo
echo "Done Adding Aliases"
echo "Adding Filter Alias"
curl -s -XPOST "http://$ADDRESS/_aliases" -d '
{
"actions" : [
{
"add" : {
"index" : "december_2014_invoices",
"alias" : "bigmoney",
"filter" :
{
"range" :
{
"revenue" :
{
"gt" : 1000
}
}
}
}
}
]
}'
echo
echo "Done Adding Filter Alias"
echo
echo "Adding Routing Alias"
curl -s -XPOST "http://$ADDRESS/_aliases" -d '
{
"actions" : [
{
"add" : {
"index" : "december_2014_invoices",
"alias" : "2014_invoices",
"search_routing" : "en,es",
"index_routing" : "en"
}
}
]
}'
echo
echo "Done Adding Routing Alias"
echo