Skip to content

Instantly share code, notes, and snippets.

@johntbush
Created May 24, 2015 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johntbush/89b66a79beadebc9d713 to your computer and use it in GitHub Desktop.
Save johntbush/89b66a79beadebc9d713 to your computer and use it in GitHub Desktop.
reindex field
updates="1"
while [ $updates -gt 0 ]
do
updates=`curl -s http://localhost:9200/fps-fbs_c94c36b8-e425-4bb8-b291-4b34f96d74ca*/_search -d '{
"size" : 500,
"_source" : ["FbKey"],
"query" : {
"filtered" :{
"query" : {
"multi_match" : {
"fields" : ["FbKey"],
"query" : "0",
"type" : "phrase_prefix"
}
},
"filter" : {
"missing" : {
"field" : "FbKey.no_pad"
}
}
}
}
}' | \
jq -c '.hits.hits[] | { "update" : {"_index" : ._index, "_id" :._id, "_type" : ._type}}, { "doc" : {"FbKey": ._source.FbKey}}' | \
curl -s -XPOST --data-binary @- http://localhost:9200/_bulk | \
jq '.items | length'`
echo "updated $updates records"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment