Skip to content

Commit

Permalink
Update Elasticsearch mappings for ES 6
Browse files Browse the repository at this point in the history
Reduce amount of data stored, remove aliases, and update for ES 6
compatibility. This is a precursor to #82.

Reindexing steps:

1. Update ES config:

reindex.remote.whitelist=OLD_HOST:9200

2. Reindex from remote:

curl -XPOST 'NEW_HOST:9200/_reindex' -H "Content-Type: application/json" -d '
{
  "source": {
    "remote": {
      "host": "http://OLD_HOST:9200"
    },
    "index": "item_fulltext_index"
  },
  "dest": {
    "index": "item_fulltext_index",
    "version_type": "external_gt"
  },
  "script": {
    "source": "ctx._version = ctx._source.version",
    "lang": "painless"
  }
}'
  • Loading branch information
dstillman committed Jan 17, 2019
1 parent 545ed21 commit 2179533
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 56 deletions.
14 changes: 0 additions & 14 deletions misc/elasticsearch/aliases.json-sample

This file was deleted.

14 changes: 5 additions & 9 deletions misc/elasticsearch/bin/init
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 host index_suffix"
if [ -z "$1" ]; then
echo "Usage: $0 host"
exit
fi
HOST="$1"
INDEX_SUFFIX="$2"

# Get path to script's parent directory
DIR=$(cd ${0%/*} && echo $PWD/${0##*/})
DIR=`dirname $DIR`
DIR=`dirname $DIR`
ITEM_FULLTEXT_DIR=$DIR/item_fulltext

curl -XPUT "http://$HOST:9200/item_fulltext_index_$INDEX_SUFFIX" -d @$ITEM_FULLTEXT_DIR/init.json
curl -XPUT "http://$HOST:9200/item_fulltext_index" -H "Content-Type: application/json" -d @$ITEM_FULLTEXT_DIR/init.json
echo

$DIR/bin/update-settings $HOST $INDEX_SUFFIX
$DIR/bin/update-settings $HOST

curl -XPUT "http://$HOST:9200/item_fulltext_index_$INDEX_SUFFIX/item_fulltext/_mapping" -d @$ITEM_FULLTEXT_DIR/mapping.json
echo

curl -XPOST "http://$HOST:9200/_aliases" -d @aliases.json
curl -XPUT "http://$HOST:9200/item_fulltext_index/item_fulltext/_mapping" -H "Content-Type: application/json" -d @$ITEM_FULLTEXT_DIR/mapping.json
echo
15 changes: 0 additions & 15 deletions misc/elasticsearch/bin/update-aliases

This file was deleted.

7 changes: 3 additions & 4 deletions misc/elasticsearch/bin/update-settings
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/bin/sh

if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 host index_suffix"
if [ -z "$1" ]; then
echo "Usage: $0 host"
exit
fi
HOST="$1"
INDEX_SUFFIX="$2"

# Get path to script's parent directory
DIR=$(cd ${0%/*} && echo $PWD/${0##*/})
DIR=`dirname $DIR`
DIR=`dirname $DIR`
ITEM_FULLTEXT_DIR=$DIR/item_fulltext

curl -XPUT "http://$HOST:9200/item_fulltext_index_$INDEX_SUFFIX/_settings" -d @$ITEM_FULLTEXT_DIR/settings.json
curl -XPUT "http://$HOST:9200/item_fulltext_index/_settings" -H "Content-Type: application/json" -d @$ITEM_FULLTEXT_DIR/settings.json
echo
25 changes: 11 additions & 14 deletions misc/elasticsearch/item_fulltext/mapping.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"item_fulltext": {
"properties": {
"libraryID": { "type": "integer" },
"content": { "type": "string" },
"version": { "type": "integer" },
"timestamp": { "type": "date", "format": "dateHourMinuteSecond" },
"indexedChars": { "type": "integer", "index" : "no" },
"totalChars": { "type": "integer", "index" : "no" },
"indexedPages": { "type": "integer", "index" : "no" },
"totalPages": { "type": "integer", "index" : "no" }
},
"_all": {
"_source": {
"enabled": false
},
"properties": {
"libraryID": {
"type": "integer"
},
"content": {
"type": "text"
}
},
"_routing": {
"required": true,
"path": "libraryID"
"required": true
},
"dynamic" : false
"dynamic": false
}
}

0 comments on commit 2179533

Please sign in to comment.