# Delete all?

**URL:** <https://discuss.elastic.co/t/delete-all/7189>\
**Category:** Elasticsearch\
**Created:** [March 31, 2012, 7:44pm UTC](https://discuss.elastic.co/t/delete-all/7189 "2012-03-31T19:44:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [March 31, 2012, 7:44pm UTC](https://discuss.elastic.co/t/delete-all/7189/1 "2012-03-31T19:44:23Z")

</div>

Does elasticsearch have a setting to clear all existing indexes on  
startup?

This isn't for an April Fool's joke, but would be convenient for unit  
tests (since there is no disk-less option), and also during  
development.

---

<div class="post-metadata">

**Author:** ![Michael\_Sick](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Michael\_Sick](https://discuss.elastic.co/u/Michael_Sick)\
**Post date:** [March 31, 2012, 7:57pm UTC](https://discuss.elastic.co/t/delete-all/7189/2 "2012-03-31T19:57:06Z")

</div>

Eric,

You could delete/create the index (that's what I have done) or I imagine  
you could use the delete by query API and use a match\_all.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--Mike

On Sat, Mar 31, 2012 at 3:44 PM, Eric Jain [eric.jain@gmail.com](mailto:eric.jain@gmail.com) wrote:

> Does elasticsearch have a setting to clear all existing indexes on  
> startup?
> 
> This isn't for an April Fool's joke, but would be convenient for unit  
> tests (since there is no disk-less option), and also during  
> development.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 31, 2012, 8:48pm UTC](https://discuss.elastic.co/t/delete-all/7189/3 "2012-03-31T20:48:40Z")

</div>

If you use Java and Spring, you can use my Spring factory for that :

> **[GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch](https://github.com/dadoonet/spring-elasticsearch)**
>
> Spring factories for elasticsearch. Contribute to dadoonet/spring-elasticsearch development by creating an account on GitHub.

See forceReinit

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 31 mars 2012 à 21:44, Eric Jain [eric.jain@gmail.com](mailto:eric.jain@gmail.com) a écrit :

> Does elasticsearch have a setting to clear all existing indexes on  
> startup?
> 
> This isn't for an April Fool's joke, but would be convenient for unit  
> tests (since there is no disk-less option), and also during  
> development.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [March 31, 2012, 8:58pm UTC](https://discuss.elastic.co/t/delete-all/7189/4 "2012-03-31T20:58:18Z")

</div>

This is not exactly an answer to your question, but there are settings that  
prevent indices from being saved between cluster restarts:

gateway.type: none  
index.store.type: memory

On Saturday, March 31, 2012 3:44:23 PM UTC-4, Eric Jain wrote:

> Does elasticsearch have a setting to clear all existing indexes on  
> startup?
> 
> This isn't for an April Fool's joke, but would be convenient for unit  
> tests (since there is no disk-less option), and also during  
> development.

---

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [March 31, 2012, 9:49pm UTC](https://discuss.elastic.co/t/delete-all/7189/5 "2012-03-31T21:49:48Z")

</div>

On Sat, Mar 31, 2012 at 13:58, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> This is not exactly an answer to your question, but there are settings that  
> prevent indices from being saved between cluster restarts:
> 
> gateway.type: none  
> index.store.type: memory

That's what I was looking for, thanks.

---

<div class="post-metadata">

**Author:** ![spokarna](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@spokarna](https://discuss.elastic.co/u/spokarna)\
**Post date:** [August 23, 2012, 6:25am UTC](https://discuss.elastic.co/t/delete-all/7189/6 "2012-08-23T06:25:42Z")

</div>

ElasticSearch allows you to create a local ES instance, that is in-memory, and the intention is to allow ES in unit tests.

Check this:  
[http://www.elasticsearch.org/guide/reference/java-api/client.html](http://www.elasticsearch.org/guide/reference/java-api/client.html)

`
import static org.elasticsearch.node.NodeBuilder.*;
// on startup
Node node = nodeBuilder().local(true).node();
Client client = node.client();
// on shutdown
node.close();
`

---

<div class="post-metadata">

**Author:** ![drewr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewr/32/7803_2.png) [@drewr](https://discuss.elastic.co/u/drewr)\
**Post date:** [August 24, 2012, 1:40pm UTC](https://discuss.elastic.co/t/delete-all/7189/7 "2012-08-24T13:40:36Z")

</div>

spokarna wrote:

> Eric wrote:
> 
> > Does elasticsearch have a setting to clear all existing indexes on  
> > startup?
> > 
> > This isn't for an April Fool's joke, but would be convenient for  
> > unit tests (since there is no disk-less option), and also during  
> > development.

> Elasticsearch allows you to create a local ES instance, that is  
> in-memory, and the intention is to allow ES in unit tests.
> 
> Check this:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/client.html)
> 
> `
> import static org.elasticsearch.node.NodeBuilder.*;
> // on startup
> Node node = nodeBuilder().local(true).node();
> Client client = node.client();
> // on shutdown
> node.close();
> `

`
"local" is not related to index storage. It is a way to localize
discovery within a single JVM and prevent nodes from clustering over
TCP. It will still store index data on disk.
What Eric wants is to set index.store.type to either "ram" (lucene's
in-heap RAMDirectory) or "memory" (ByteBufferDirectory outside of
heap).
With either of these, index data will disappear with the cluster.
-Drew
--`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 24, 2012, 1:54pm UTC](https://discuss.elastic.co/t/delete-all/7189/8 "2012-08-24T13:54:24Z")

</div>

Here are the properties I set for junit tests: [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/es.properties](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/es.properties)

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 24 août 2012 à 15:40, Drew Raines [aaraines@gmail.com](mailto:aaraines@gmail.com) a écrit :

spokarna wrote:

> Eric wrote:
> 
> > Does elasticsearch have a setting to clear all existing indexes on  
> > startup?
> > 
> > This isn't for an April Fool's joke, but would be convenient for  
> > unit tests (since there is no disk-less option), and also during  
> > development.

> Elasticsearch allows you to create a local ES instance, that is  
> in-memory, and the intention is to allow ES in unit tests.
> 
> Check this:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/client.html)
> 
> `
> import static org.elasticsearch.node.NodeBuilder.*;
> // on startup
> Node node = nodeBuilder().local(true).node();
> Client client = node.client();
> // on shutdown
> node.close();
> `

`
"local" is not related to index storage. It is a way to localize
discovery within a single JVM and prevent nodes from clustering over
TCP. It will still store index data on disk.
What Eric wants is to set index.store.type to either "ram" (lucene's
in-heap RAMDirectory) or "memory" (ByteBufferDirectory outside of
heap).
With either of these, index data will disappear with the cluster.
-Drew
--
--`

---

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [August 24, 2012, 4:27pm UTC](https://discuss.elastic.co/t/delete-all/7189/9 "2012-08-24T16:27:42Z")

</div>

On Fri, Aug 24, 2012 at 6:54 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Here are the properties I set for junit tests: [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/es.properties](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/es.properties)

Thanks; I already have these two properties set:

gateway.type=none  
index.store.type=memory

This works, but elasticsearch still creates an empty directory  
structure for the node and each index, which I need to clean up.

Adding the following two options from your es.properties doesn't seem  
to make any difference:

index.gateway.type=none  
index.store.fs.memory.enabled=true

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 24, 2012, 10:58pm UTC](https://discuss.elastic.co/t/delete-all/7189/10 "2012-08-24T22:58:01Z")

</div>

In fact Path.data is set to maven target dir.  
And here is a class that remove dir before each test:  
[https://github.com/dadoonet/fsriver/blob/master/src/test/java/org/elasticsearch/river/fs/AbstractFsRiverTest.java#L66](https://github.com/dadoonet/fsriver/blob/master/src/test/java/org/elasticsearch/river/fs/AbstractFsRiverTest.java#L66)

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 24 août 2012 à 18:27, Eric Jain [eric.jain@gmail.com](mailto:eric.jain@gmail.com) a écrit :

On Fri, Aug 24, 2012 at 6:54 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Here are the properties I set for junit tests: [https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/es.properties](https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/es.properties)

Thanks; I already have these two properties set:

gateway.type=none  
index.store.type=memory

This works, but elasticsearch still creates an empty directory  
structure for the node and each index, which I need to clean up.

Adding the following two options from your es.properties doesn't seem  
to make any difference:

index.gateway.type=none  
index.store.fs.memory.enabled=true

--

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:15am UTC](https://discuss.elastic.co/t/delete-all/7189/11 "2017-07-06T03:15:05Z")

</div>


