Greg Eremeev
Greg Eremeev

Reputation: 1840

How set max limit document in elasticsearch?

Can I set max limit number document in index elasticsearch? That when you reach that limit, old documents starts delete.

In my opinion this is not provided. Is this true? If so, how do I clean the database only from old records, after some time?

Upvotes: 0

Views: 810

Answers (2)

John Petrone
John Petrone

Reputation: 27487

There is no mechanism currently within Elasticsearch to let you cap the size of an index. However, if you want documents to be deleted after a set amount of time I'd use the ttl setting:

TTL

A document can be indexed with a ttl (time to live) associated with it. Expired documents will be expunged automatically. The expiration date that will be set for a document with a provided ttl is relative to the timestamp of the document, meaning it can be based on the time of indexing or on any time provided. The provided ttl must be strictly positive and can be a number (in milliseconds) or any valid time value

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html

Upvotes: 1

prayagupadhyay
prayagupadhyay

Reputation: 31192

No idea about individual documents, but Elasticsearch curator (python script) can (only) delete indices.

Examples

pip install elasticsearch-curator
curator delete --older-than 30     ## for localhost:9200
curator --host es-host delete --older-than 30 --prefix prod- --timestring %Y.%m.%d ## for remote server es-host where index name has prefix prod

Please read their README for details, if this fulfills your requirements.

Upvotes: 0

Related Questions