go-elasticsearch icon indicating copy to clipboard operation
go-elasticsearch copied to clipboard

index name may be double escaped

Open soranoba opened this issue 3 years ago • 3 comments

In Elasticsearch, escaped characters may be contains in index name. ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html

# PUT /<my-index-{now/d}>
PUT /%3Cmy-index-%7Bnow%2Fd%7D%3E

Notice that we have to escape the / here.

In Golang, paths are usually escaped automatically. However, / is not an escaped character. If we specify an escaped index name, it will be double escaped.

So, the library is currently not possible to use this index.


Solution: https://github.com/soranoba/go-elasticsearch/compare/master..fix/master/double-escape-path

The code will solve the problem, but what was previously escaped will no longer be escaped. It may be a breaking change.

Is there a better solution?

soranoba avatar Sep 08 '20 12:09 soranoba

Related issues: https://github.com/elastic/go-elasticsearch/issues/52

soranoba avatar Sep 09 '20 00:09 soranoba

Hello, sorry for the delay here. Correct, there's an inconsistency with regard to the / character, due to the behaviour of URL escaping in Go. As I wrote in the related issue comment, and as you mention, this is tricky to solve without breaking backwards compatibility. I imagine this is something worth looking before releasing the 8.0 version of the package.

karmi avatar Sep 28 '20 13:09 karmi

Thank you for your reply. I hope that it fixes in 8.0.

soranoba avatar Sep 28 '20 13:09 soranoba