Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set ttl. #64

Open
songoo opened this issue Jun 17, 2015 · 3 comments
Open

How to set ttl. #64

songoo opened this issue Jun 17, 2015 · 3 comments

Comments

@songoo
Copy link

songoo commented Jun 17, 2015

How can i set "ttl" "time to live" on index (so all results older than 60s would get removed from search for example https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ttl-field.html)

i tried to use custom settings part:

"## Custom settings to apply when creating the index (optional)
elasticsearch.index.settings="{'_ttl' : { 'enabled' : true, 'default' : '60s' }"

But results are still searchable even after hour. is there need for another setting or have i set it with some kind of annotation? Currently have only one annotation
"@IndexType(name = "searchResult")
public class SearchResult extends Index { ..."

Or maybe is missing specification for timestamp (also some kind of annotation?)

Tnx for help.

@nboire
Copy link
Member

nboire commented Jun 17, 2015

Hello,

The ttl must be define on Mapping and not on Setting configuration
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

So you can add via this like annotation.

@IndexMapping(value = "{ searchResult : { "_ttl" : { "enabled" : true } } }")

@songoo
Copy link
Author

songoo commented Jun 17, 2015

Tnx very much, had to escape " but it worked!

@songoo
Copy link
Author

songoo commented Jul 8, 2015

Hello again, above code work well but i got to special situation. I reindex whole search every 4 hours
SearchResult searchResult = new SearchResult();
...
searchResult.index();
Always using same ids. I also have 12 ttl by annotation.

Expected : items that are not reindexed by "searchResult.index();" will expire after 12h others wil stay.
Reality : All items get deleted after 12h, even if they are reindexed 3 times.

Is there any way to update ttl while reindexing ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants