Delete all?


(Eric Jain) #1

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.


(Michael Sick) #2

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.

http://www.elasticsearch.org/guide/reference/api/delete-by-query.html

--Mike

On Sat, Mar 31, 2012 at 3:44 PM, Eric Jain 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.


(David Pilato) #3

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

See forceReinit

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 31 mars 2012 à 21:44, Eric Jain 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.


(Igor Motov) #4

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.


(Eric Jain) #5

On Sat, Mar 31, 2012 at 13:58, Igor Motov 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.


(spokarna) #6

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

import static org.elasticsearch.node.NodeBuilder.*;

// on startup

Node node = nodeBuilder().local(true).node();
Client client = node.client();

// on shutdown

node.close();


(Drew Raines) #7

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:
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

--


(David Pilato) #8

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

HTH

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

Le 24 août 2012 à 15:40, Drew Raines 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:
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

--

--


(Eric Jain) #9

On Fri, Aug 24, 2012 at 6:54 AM, David Pilato 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

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

--


(David Pilato) #10

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

HTH

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

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

On Fri, Aug 24, 2012 at 6:54 AM, David Pilato 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

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

--

--


(system) #11