Replying on my own thread. It looks like there is a period "." in the fieldName. I tried it manually and found out that adding period at the end of the fieldname works (e.g. "myfield..."), however if there is any character after period (e.g. "myfield.x"), then it fails with the above error.
Interestingly, the error message from ES and API are different, which made it hard to debug. I had to look into ES code. I guess period makes it confusing for ES to differentiate nested and other types.
Is there any official documentation that mentions the list of illegal characters in ES? This post specifies that ".", "#" & "*" are illegal characters.