Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.
Without that it's hard to know but let's make some guesses. May be the type is actually _doc
and not test
.
You can look also at the rename processor and the reindex API. So you reindex in a new clean index instead of keeping the old mapping around.