Skip to content

Instantly share code, notes, and snippets.

@up1
Last active April 7, 2016 14:05
Show Gist options
  • Select an option

  • Save up1/d03e1ba2aad382cdd1f521a9a12f716c to your computer and use it in GitHub Desktop.

Select an option

Save up1/d03e1ba2aad382cdd1f521a9a12f716c to your computer and use it in GitHub Desktop.
Elasticsearch RE-indexing
curl -XPOST 'localhost:9200/sample_new' -d '{
"mappings" : {
"videos" : {
"properties" : {
"tags" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}'
curl -XPOST 'localhost:9200/_reindex' -d '{
"size" : 3,
"source" : {
"index" : "sample",
"type" : "videos",
"query" : {
"term" : {
"tags" : "elasticsearch"
}
},
"sort" : {
"upload_date" : "desc"
}
},
"dest" : {
"index" : "sample_new"
}
}'
curl -XPOST 'localhost:9200/_reindex' -d '{
"source" : {
"index" : "sample"
},
"dest" : {
"index" : "sample_new",
"version_type": "external"
}
}'
curl -XPOST 'localhost:9200/sample_new' -d '{
"mappings" : {
"videos" : {
"properties" : {
"tags" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}'
cd ./sample-documents
for file in *.json; do
echo -n $file
curl -XPOST localhost:9200/sample_new/videos/ -d "`cat $file`"
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment