Renaming Files and Directories
So far, so good. Renaming a file is easy—a simple
index request is all that is required. You can even use optimistic concurrency control to ensure that your change doesn’t conflict with the changes from another user:
"Starting a new Elasticsearch project is easy..."
versionnumber ensures that the change is applied only if the document in the index has this same version number.
We can even rename a directory, but this means updating all of the files that exist anywhere in the path hierarchy beneath that directory. This may be quick or slow, depending on how many files need to be updated. All we would need to do is to use scan-and-scroll to retrieve all the files, and the
bulk API to update them. The process isn’t atomic, but all files will quickly move to their new home.