This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE localhost:9200/test | |
#{"ok":true,"acknowledged":true} | |
curl -XPOST localhost:9200/test/test/ -d '{"timestamp": "random_date", "tag":"red", "counter": 3}' | |
#{"ok":true,"_index":"test","_type":"test","_id":"MLv-xERyTFaIdkQeaxoiaw","_version":1} | |
curl -XPOST localhost:9200/test/test/ -d '{"timestamp": "random_date", "tag":"red", "counter": 7}' | |
#{"ok":true,"_index":"test","_type":"test","_id":"JaMQIZpbQaKrgdTOtaEEcg","_version":1} | |
curl -XPOST localhost:9200/test/test/ -d '{"timestamp": "random_date", "tag":"blue", "counter": 5}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat inserter.py | |
import pyes | |
import sys | |
conn = pyes.ES('127.0.0.1:9200', bulk_size=int(sys.argv[2])) | |
for i in range(int(sys.argv[1])): | |
conn.index({"name":"Joe Tester", "parsedtext":"Joe Testere nice guy", "uuid":"11111", "position":1}, "test-index", "test-type", bulk=True) | |
$ time python inserter.py 1000 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#delete the test index | |
curl -XDELETE localhost:9200/testing/ | |
echo | |
#put the document | |
curl -XPOST localhost:9200/testing/testing/ -d '{ | |
"document": { | |
"title": "foo", | |
"id": 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#delete the test type | |
curl -XDELETE localhost:9200/test/test2/ | |
#insert some docs###### | |
curl -XPOST localhost:9200/test/test2/ -d '{ | |
"id": 123, | |
"a": 10, | |
"b": 12, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURRENTINDEX="test" | |
NEWINDEX="newindex" | |
#where the indices are stored within the DATADIR | |
INDICESDIR=/var/lib/elasticsearch/elasticsearch/nodes/0/indices/ | |
#get the metadata for the current index | |
curl localhost:9200/$CURRENTINDEX/_settings?pretty=true > /tmp/settings | |
curl localhost:9200/$CURRENTINDEX/_mapping?pretty=true > /tmp/mappings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo ===Removing everything=== | |
curl -XDELETE localhost:9200/test | |
echo | |
echo ===Putting empty index=== | |
curl -XPUT localhost:9200/test | |
echo | |
echo ====Putting mapping=== | |
curl -XPUT localhost:9200/test/test/_mapping -d '{ | |
"test": { | |
"properties": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
###############FUNCTIONS############ | |
function prepare { | |
#optimize the index | |
echo -n "Optimizing index $INDEX_NAME..." | |
curl -XPOST "$ADDRESS/$INDEX_NAME/_optimize" 2>/dev/null| grep 'failed":0' >/dev/null | |
if [ $? -eq 0 ]; then | |
echo "done" |
NewerOlder