Delete all?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete all?

Eric Jain
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.
Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

Michael Sick
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 <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

dadoonet
In reply to this post by Eric Jain
If you use Java and Spring, you can use my Spring factory for that : 

See forceReinit

David ;-)
Twitter : @dadoonet / @elasticsearchfr

Le 31 mars 2012 à 21:44, Eric Jain <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

Igor Motov-3
In reply to this post by Eric Jain
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.
Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

Eric Jain
On Sat, Mar 31, 2012 at 13:58, Igor Motov <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

spokarna
In reply to this post by Eric Jain
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

<code>
import static org.elasticsearch.node.NodeBuilder.*;

// on startup

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

// on shutdown

node.close();
</code>
Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

Drew Raines-2
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
>
> <code>
> 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

--


Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

dadoonet
Here are the properties I set for junit tests: 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 <[hidden email]> 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
>
> <code>
> 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

--


--


Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

Eric Jain
On Fri, Aug 24, 2012 at 6:54 AM, David Pilato <[hidden email]> 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

--


Reply | Threaded
Open this post in threaded view
|

Re: Delete all?

dadoonet
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 ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs


Le 24 août 2012 à 18:27, Eric Jain <[hidden email]> a écrit :

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

--


--