Using TTL and Timestamp


(Ravi Dontharaju) #1

Hi,
I am using the Java API to do my operations on ES.

I am trying to insert/use the _ttl and _timestamp features.
The question that I had is, should I be setting the _ttl and _timestamp in the XContentBuilder source document that I pass to .setSource while building by IndexRequestBuilder?
Or should I be setting my _ttl and _timestamp using the .setTTL(long) and .setTimestamp(String) methods while building my IndexRequestBuilder?

I tried both, and both did not remove my documents after a given while. The input for setTTL is long, and hence I am assuming that it accepts milliseconds, right?

Also, when I use .setTTL and .setTimestamp, while debugging, I can see that ttl and timestamp values have been updated for the request field under IndexRequestBuilder, but it does not reflect the fields in the document when I curl for it.

I am using Joda.DateTime.toString to add to the timestamp.

TL;DR
How can I utilize/use _ttl and _timestamp using JavaAPI :slight_smile:

Thanks,
Ravi Dontharaju


(Benjamin Devèze) #2

Hey Ravi

Have you enabled ttl and timestamp fields in your mapping?

You should use setTTL and setTimestamp methods when using the java API.

Le vendredi 6 avril 2012, Ravi Dontharaju a écrit :

Hi,
I am using the Java API to do my operations on ES.

I am trying to insert/use the _ttl and _timestamp features.
The question that I had is, should I be setting the _ttl and _timestamp in
the XContentBuilder source document that I pass to .setSource while
building
by IndexRequestBuilder?
Or should I be setting my _ttl and _timestamp using the .setTTL(long) and
.setTimestamp(String) methods while building my IndexRequestBuilder?

I tried both, and both did not remove my documents after a given while. The
input for setTTL is long, and hence I am assuming that it accepts
milliseconds, right?

Also, when I use .setTTL and .setTimestamp, while debugging, I can see that
ttl and timestamp values have been updated for the request field under
IndexRequestBuilder, but it does not reflect the fields in the document
when
I curl for it.

I am using Joda.DateTime.toString to add to the timestamp.

TL;DR
How can I utilize/use _ttl and _timestamp using JavaAPI :slight_smile:

Thanks,
Ravi Dontharaju

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Using-TTL-and-Timestamp-tp3891197p3891197.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

--
Benjamin DEVEZE


(system) #3