Skip to content

Instantly share code, notes, and snippets.

@adkatrit
Last active August 29, 2015 14:02

Revisions

  1. adkatrit revised this gist Aug 26, 2015. 1 changed file with 30 additions and 43 deletions.
    73 changes: 30 additions & 43 deletions elastic-indexing.sh
    Original file line number Diff line number Diff line change
    @@ -1,68 +1,55 @@
    #!/bin/bash

    INDEX="corp-reg"
    ES_SOCKET="10.0.1.109:9200"

    if [[ -z "$1" ]];
    then $INDEX = $1
    else exit 1
    fi
    #Create index
    curl -XPUT "localhost:55559/$INDEX/"
    curl -XPUT "$ES_SOCKET/$INDEX/"

    #replicas
    curl -XPUT "$ES_SOCKET/$INDEX/_settings" -d '{
    "index" : {
    "number_of_replicas" : 0
    }
    }'

    echo "";
    #Close index
    curl -XPOST "localhost:55559/$INDEX/_close"
    curl -XPOST "$ES_SOCKET/$INDEX/_close"
    echo "";

    #refresh rate
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    curl -XPUT "$ES_SOCKET/$INDEX/_settings" -d '{
    "index" : {
    "refresh_interval" :-1
    }
    }'

    echo "";

    #merge policy
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    curl -XPUT "$ES_SOCKET/$INDEX/_settings" -d '{
    "index" : {
    "index.merge.policy.merge_factor" : 30
    }
    }'

    #replicas
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "index" : {
    "number_of_replicas" : 0
    }
    }'
    echo "";

    #flush -- only necessary for bulk loading
    #curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    #"index":{
    #"index.translog.flush_threshold_size":10000
    #}
    #}'

    curl -XPUT "$ES_SOCKET/$INDEX/_settings" -d '{
    "index":{
    "index.translog.flush_threshold_size":10000
    }
    }'
    echo "";

    #buffer
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    curl -XPUT "$ES_SOCKET/$INDEX/_settings" -d '{
    "index":{
    "indices.memory.index_buffer_size": 30
    }
    }'
    echo "";

    #create the index
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "mappings":{
    "raw_data":{
    "properties":{
    "datapath":{
    "type":"string",
    "index":"not_analyzed"
    },
    "location":{
    "type":"geo-point",
    "geohash":true
    }
    }
    }
    }
    }'
    curl -XPOST "$ES_SOCKET/$INDEX/_open"
    echo "";

    curl -XPOST "localhost:55559/$INDEX/_open"
  2. adkatrit created this gist Jun 20, 2014.
    68 changes: 68 additions & 0 deletions elastic-indexing.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@

    if [[ -z "$1" ]];
    then $INDEX = $1
    else exit 1
    fi
    #Create index
    curl -XPUT "localhost:55559/$INDEX/"

    #Close index
    curl -XPOST "localhost:55559/$INDEX/_close"


    #refresh rate
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "index" : {
    "refresh_interval" :-1
    }
    }'

    #merge policy
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "index" : {
    "index.merge.policy.merge_factor" : 30
    }
    }'

    #replicas
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "index" : {
    "number_of_replicas" : 0
    }
    }'

    #flush -- only necessary for bulk loading
    #curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    #"index":{
    #"index.translog.flush_threshold_size":10000
    #}
    #}'


    #buffer
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "index":{
    "indices.memory.index_buffer_size": 30
    }
    }'


    #create the index
    curl -XPUT "localhost:55559/$INDEX/_settings" -d '{
    "mappings":{
    "raw_data":{
    "properties":{
    "datapath":{
    "type":"string",
    "index":"not_analyzed"
    },
    "location":{
    "type":"geo-point",
    "geohash":true
    }
    }
    }
    }
    }'

    curl -XPOST "localhost:55559/$INDEX/_open"