我想从ElasticSearch索引返回最近的记录(前1个),类似于下面的sql查询;
SELECT TOP 1 Id, name, title FROM MyTable ORDER BY Date DESC;
能做到吗?
你有_timestamp在您的文档映射启用?
{ "doctype": { "_timestamp": { "enabled": "true", "store": "yes" }, "properties": { ... } } }
您可以在此处检查映射:
http://localhost:9200/_all/_mapping
如果是这样,我认为这可能会获得最新的信息:
{ "query": { "match_all": {} }, "size": 1, "sort": [ { "_timestamp": { "order": "desc" } } ] }