How to delete all available Documents from index Type?

Hi

My index contain many index Type,I want to delete all document from given
index type, i have try on following query:

TermQueryBuilder termQueryBuilder = new
TermQueryBuilder("_type", indexType);

    DeleteByQueryResponse response = client
                                     .prepareDeleteByQuery(indexName)
                                     .setQuery(termQueryBuilder)
                                     .execute()
                                     .actionGet();

where indexName represent the index name and type is inexType which came
from other side.when i execute this query,i assume that indextype is
deleted as well as all document which depend on indexType,but when i try to
index a document with same indexType and document id,i got the following
error:

org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException:
[idx_masterdatabase][4] [type_testtable][3]: document already exists
at
org.elasticsearch.index.engine.robin.RobinEngine.innerCreate(RobinEngine.java:349)
at
org.elasticsearch.index.engine.robin.RobinEngine.create(RobinEngine.java:266)
at
org.elasticsearch.index.shard.service.InternalIndexShard.create(InternalIndexShard.java:272)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:136)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:331)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

In the Java API, you have the option ot delete a mapping with its data,
client.admin().indices().prepareDeleteMapping

On Tue, Apr 24, 2012 at 4:52 PM, sam mishra.sameek@gmail.com wrote:

Hi

My index contain many index Type,I want to delete all document from given
index type, i have try on following query:

TermQueryBuilder termQueryBuilder = new
TermQueryBuilder("_type", indexType);

    DeleteByQueryResponse response = client
                                     .prepareDeleteByQuery(indexName)
                                     .setQuery(termQueryBuilder)
                                     .execute()
                                     .actionGet();

where indexName represent the index name and type is inexType which came
from other side.when i execute this query,i assume that indextype is
deleted as well as all document which depend on indexType,but when i try to
index a document with same indexType and document id,i got the following
error:

org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException:
[idx_masterdatabase][4] [type_testtable][3]: document already exists
at
org.elasticsearch.index.engine.robin.RobinEngine.innerCreate(RobinEngine.java:349)
at
org.elasticsearch.index.engine.robin.RobinEngine.create(RobinEngine.java:266)
at
org.elasticsearch.index.shard.service.InternalIndexShard.create(InternalIndexShard.java:272)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:136)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:331)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Hi -
Is there a method (Java API) to check whether the TYPE exists before we try
to delete its mapping?

On Friday, April 27, 2012 1:49:49 AM UTC-7, kimchy wrote:

In the Java API, you have the option ot delete a mapping with its data,
client.admin().indices().prepareDeleteMapping

On Tue, Apr 24, 2012 at 4:52 PM, sam <mishra...@gmail.com <javascript:>>wrote:

Hi

My index contain many index Type,I want to delete all document from given
index type, i have try on following query:

TermQueryBuilder termQueryBuilder = new
TermQueryBuilder("_type", indexType);

    DeleteByQueryResponse response = client
                                     .prepareDeleteByQuery(indexName)
                                     .setQuery(termQueryBuilder)
                                     .execute()
                                     .actionGet();

where indexName represent the index name and type is inexType which came
from other side.when i execute this query,i assume that indextype is
deleted as well as all document which depend on indexType,but when i try to
index a document with same indexType and document id,i got the following
error:

org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException:
[idx_masterdatabase][4] [type_testtable][3]: document already exists
at
org.elasticsearch.index.engine.robin.RobinEngine.innerCreate(RobinEngine.java:349)
at
org.elasticsearch.index.engine.robin.RobinEngine.create(RobinEngine.java:266)
at
org.elasticsearch.index.shard.service.InternalIndexShard.create(InternalIndexShard.java:272)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:136)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:331)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

--

You could fire a query for documents of the TYPE.

Op zaterdag 19 januari 2013 00:39:34 UTC+1 schreef Mxims het volgende:

Hi -
Is there a method (Java API) to check whether the TYPE exists before we
try to delete its mapping?

On Friday, April 27, 2012 1:49:49 AM UTC-7, kimchy wrote:

In the Java API, you have the option ot delete a mapping with its data,
client.admin().indices().prepareDeleteMapping

On Tue, Apr 24, 2012 at 4:52 PM, sam mishra...@gmail.com wrote:

Hi

My index contain many index Type,I want to delete all document from
given index type, i have try on following query:

TermQueryBuilder termQueryBuilder = new
TermQueryBuilder("_type", indexType);

    DeleteByQueryResponse response = client
                                     .prepareDeleteByQuery(indexName)
                                     .setQuery(termQueryBuilder)
                                     .execute()
                                     .actionGet();

where indexName represent the index name and type is inexType which came
from other side.when i execute this query,i assume that indextype is
deleted as well as all document which depend on indexType,but when i try to
index a document with same indexType and document id,i got the following
error:

org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException:
[idx_masterdatabase][4] [type_testtable][3]: document already exists
at
org.elasticsearch.index.engine.robin.RobinEngine.innerCreate(RobinEngine.java:349)
at
org.elasticsearch.index.engine.robin.RobinEngine.create(RobinEngine.java:266)
at
org.elasticsearch.index.shard.service.InternalIndexShard.create(InternalIndexShard.java:272)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:136)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:331)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

--

Hmm, that would only work if there exist document of the TYPE. See "Using
Java API, how do I find out whether a given type exists in the index?" for
a better answer.

Op zaterdag 19 januari 2013 12:50:53 UTC+1 schreef Edward Smit het volgende:

You could fire a query for documents of the TYPE.

Op zaterdag 19 januari 2013 00:39:34 UTC+1 schreef Mxims het volgende:

Hi -
Is there a method (Java API) to check whether the TYPE exists before we
try to delete its mapping?

On Friday, April 27, 2012 1:49:49 AM UTC-7, kimchy wrote:

In the Java API, you have the option ot delete a mapping with its data,
client.admin().indices().prepareDeleteMapping

On Tue, Apr 24, 2012 at 4:52 PM, sam mishra...@gmail.com wrote:

Hi

My index contain many index Type,I want to delete all document from
given index type, i have try on following query:

TermQueryBuilder termQueryBuilder = new
TermQueryBuilder("_type", indexType);

    DeleteByQueryResponse response = client

.prepareDeleteByQuery(indexName)
.setQuery(termQueryBuilder)
.execute()
.actionGet();

where indexName represent the index name and type is inexType which
came from other side.when i execute this query,i assume that indextype is
deleted as well as all document which depend on indexType,but when i try to
index a document with same indexType and document id,i got the following
error:

org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException:
[idx_masterdatabase][4] [type_testtable][3]: document already exists
at
org.elasticsearch.index.engine.robin.RobinEngine.innerCreate(RobinEngine.java:349)
at
org.elasticsearch.index.engine.robin.RobinEngine.create(RobinEngine.java:266)
at
org.elasticsearch.index.shard.service.InternalIndexShard.create(InternalIndexShard.java:272)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:136)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:331)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

--

Thank you Edward for your help!

I did refer to the answer on the other post.

Renjith from Seattle

On Saturday, January 19, 2013 3:54:12 AM UTC-8, Edward Smit wrote:

Hmm, that would only work if there exist document of the TYPE. See "Using
Java API, how do I find out whether a given type exists in the index?" for
a better answer.

Op zaterdag 19 januari 2013 12:50:53 UTC+1 schreef Edward Smit het
volgende:

You could fire a query for documents of the TYPE.

Op zaterdag 19 januari 2013 00:39:34 UTC+1 schreef Mxims het volgende:

Hi -
Is there a method (Java API) to check whether the TYPE exists before we
try to delete its mapping?

On Friday, April 27, 2012 1:49:49 AM UTC-7, kimchy wrote:

In the Java API, you have the option ot delete a mapping with its data,
client.admin().indices().prepareDeleteMapping

On Tue, Apr 24, 2012 at 4:52 PM, sam mishra...@gmail.com wrote:

Hi

My index contain many index Type,I want to delete all document from
given index type, i have try on following query:

TermQueryBuilder termQueryBuilder = new
TermQueryBuilder("_type", indexType);

    DeleteByQueryResponse response = client

.prepareDeleteByQuery(indexName)
.setQuery(termQueryBuilder)
.execute()
.actionGet();

where indexName represent the index name and type is inexType which
came from other side.when i execute this query,i assume that indextype is
deleted as well as all document which depend on indexType,but when i try to
index a document with same indexType and document id,i got the following
error:

org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException:
[idx_masterdatabase][4] [type_testtable][3]: document already exists
at
org.elasticsearch.index.engine.robin.RobinEngine.innerCreate(RobinEngine.java:349)
at
org.elasticsearch.index.engine.robin.RobinEngine.create(RobinEngine.java:266)
at
org.elasticsearch.index.shard.service.InternalIndexShard.create(InternalIndexShard.java:272)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:136)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:331)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

--