_reindex is not working when i pass index names as a variable

Hi All,

_reindex is not working when i pass index names as a variable.

###Create New index for Backup

index_name="test"
create_index="test-bkp"

curl -s -u username:password -XPUT "http://localhost:9200/$create_index"

###Copy Existing Index

curl -s -u username:password -XPOST 'http://localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
"source": {
"index": "$index_name"
},
"dest": {
"index": "$create_index"
}
}
'

=== Working if i speicfy index names like below

###Create New index for Backup

index_name="test"
create_index="test-bkp"

curl -s -u username:password -XPUT "http://localhost:9200/$create_index"

###Copy Existing Index

curl -s -u username:password -XPOST 'http://localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
"source": {
"index": "test"
},
"dest": {
"index": "test-bkp"
}
}
'

Could any one suggest as i am trying to automate this with shell script

Thanks

This link has same question about the fact variables will not be extended when placed between single quotes : https://stackoverflow.com/questions/13341955/how-to-pass-a-variable-in-a-curl-command-in-shell-scripting

Hi Julien,

Thanks or the response.

But my scenario is different, As per the link with in curl command we can able to pass the fact variables.

Here i am trying to pass the fact variables in fields but it is not accepting

Hi Julien,

Sorry, i got.

It's working now.

Thank you so much :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.