load.sh 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. echo "Generating bulk indexable shakespeare lines with timestamp 6 hours in the past and 24ish hours into the future"
  3. node reader.js > indexme.json
  4. echo "Setting mapping for shakespeare index"
  5. curl -XPUT http://localhost:9200/_template/shakespeare -d '
  6. {
  7. "template" : "shakespeare",
  8. "mappings" : {
  9. "_default_" : {
  10. "properties" : {
  11. "clientip" : { "type" : "ip" },
  12. "speaker" : {"type": "string", "index" : "not_analyzed" },
  13. "play_name" : {"type": "string", "index" : "not_analyzed" },
  14. "line_id" : { "type" : "integer", "index": "not_analyzed" },
  15. "speech_number" : { "type" : "integer", "index": "not_analyzed" },
  16. "geo" : {
  17. "properties": {
  18. "state" : {"type": "string", "index" : "not_analyzed" },
  19. "country" : {"type": "string", "index" : "not_analyzed" }
  20. }
  21. }
  22. }
  23. }
  24. }
  25. }
  26. '
  27. echo
  28. echo "Performing bulk indexing into localhost:9200"
  29. curl -XPUT localhost:9200/_bulk --data-binary @indexme.json;echo
  30. echo
  31. echo "If tons of JSON just scrolled above, I've probably successfully loaded over 100,000 lines of shakespeare into localhost:9200/shakespeare"