Low-level user here. I'm trying to clone and then delete in order to rename an index.
Before cloning I'm told (here) I should execute this "index.blocks.write" command.
This is my attempt (Python):
ES_URL = 'https://localhost:9500' # yes, running on that Port
TEMP_INDEX_NAME = 'temp_index'
data = {
'settings': {
'index.blocks.write': True,
}
}
headers = {'Content-type': 'application/json'}
# NB the auth and verify stuff is definitely working
requests.put(f'{ES_URL}/{TEMP_INDEX_NAME}/_settings', data=data, headers=headers, auth=auth, verify=verify)
... gets 400 "Bad Request"
And in fact, if I omit that, and just try for the clone, I also get 400:
The payload is wrong, there is no top-level settings and also there is a comma after True, but you do not have another item. [check the documentation].
Thanks very much. This is very puzzling. I tried various permutations of what you suggested. true (lower-case "t") on its own doesn't work in Python: it is illegal. But I tried with the string "true".
Also, in Python, a dictionary (dict) takes no account of a trailing comma after the last key-value pair.
But I tried with both True and string "true" with both your suggestions. And I'm still getting 400.
PS I also checked out that documentation page you linked to. But it's quite general, not covering "blocks.write" stuff.
I found the solution. In fact this command (as suggested by leandrojmp) worked fine when I ran it in Insomnia... but not when I use Python code. Checking various questions on this at Stack Overflow I found the solution:
data = json.dumps({
'index': {
'blocks.write': True
}
})
... i.e. submitting the dict didn't work. Submitting a string of the dict does. This is extremely surprising as I've been using dict directly since... years! (and have never encountered this issue before ever, to my knowledge).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.