load.sh 1.0 KB

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. echo "Generating bulk indexable shakespeare lines with timestamp 3 hours in the past and 10 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. "state" : {"type": "string", "index" : "not_analyzed" },
  17. "country" : {"type": "string", "index" : "not_analyzed" }
  18. }
  19. }
  20. }
  21. }
  22. '
  23. echo
  24. echo "Performing bulk indexing into localhost:9200"
  25. curl -XPUT localhost:9200/_bulk --data-binary @indexme.json;echo
  26. echo
  27. echo "If tons of JSON just scrolled above, I've probably successfully loaded over 100,000 lines of shakespeare into localhost:9200/shakespeare"