Getting DocumentAlreadyExistException even if there is no document?


(cheepu) #1

Hi all,

            I am deleting an indextype and again creating indextype in 

the same index with same indextype name.
When i create indextype with same name, i get the exception that
"DocumentAlredyExist" As I know that this exception is raised when there
exist an document with same id. But I have deleted my indextype then there
is no question of the existance of any document. I also check indextype
existance by checking metadata of index(before creating indextype); there
also I get that no indextype exist. Now it is sucking me that why this
exception is raised. Also I have observer that If i repeat the task of
deletion and creation of indextype; sometime i get this exception and some
time not.

I am checking existence of indextype as follows:

ClusterStateResponse response =
client.admin().cluster().prepareState().execute().actionGet();
ImmutableMap<String, MappingMetaData> mappings =
response.state().getMetaData().index(indexName).getMappings();
boolean hasIndexType = mappings.containsKey(indexType);

Following way is used to delete indextype:

DeleteMappingResponse actionGet =
client.admin().indices().prepareDeleteMapping(indexName).setType(indexType).execute().actionGet();
RefreshRequestBuilder prepareRefresh =
client.admin().indices().prepareRefresh(indexName);
RefreshResponse refreshActionGet =
prepareRefresh.execute().actionGet();

Thanks
Cheepu


(system) #2