I installed debian package
I am able to push data using curl:
curl -XPUT 'http://mybox:9200/blog/user/dilbert' -d '{
"name": "Dilbert Brown"
}'
And fetch it
curl -XGET 'http://mybox:9200/blog/user/dilbert'
result:
{
"_index": "blog",
"_type": "user",
"_id": "dilbert",
"_version": 2,
"exists": true,
"_source": {
"name": "Dilbert Brown"
}
}
And find it with
curl -XGET 'http://mybox:9200/blog/user/_search?q=name:Dilbert+Brown&pretty=True'
I want to push the same record with ttl of 5 seconds and 5 seconds later get 404 http status code when trying to fetch this entry. Also the entry should not be visible in search results.
NOTE: I tried various combinations of search configurations from
None of them helped me out.
Can somebody mention a simple sequence of steps that would let me achieve the targeted outcome?
TTL, or time to live, is a setting that can be applied to documents in Elasticsearch to automatically remove them after a certain amount of time has passed. This is useful for data that is only relevant for a short period of time, such as log data or temporary data.
Elasticsearch indexes are just files and they effectively cached in RAM by system. Usually if you have enough RAM Elasticsearch should work as fast as possible, especially for GET queries.
You could have one document per product or one document per order. There is no limit to how many documents you can store in a particular index.
x. Types are deprecated in APIs in 7.0, with breaking changes to the index creation, put mapping, get mapping, put template, get template and get field mappings APIs.
Here is what works for me:
curl -XPUT 'http://localhost:9200/blog/user/_mapping' -d '{"user": {"_ttl": {"enabled": true, "default": 5000}}}'
curl -XPUT 'http://localhost:9200/blog/user/phb' -d '{"name" : "Pointy-Haired Boss"}'
sleep 60 # this is the default deletion interval for the expired documents
curl -XGET http://localhost:9200/blog/user/phb # 404
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With