我试图在我的索引/文档类型中找到最后 30 个条目
我什么都没试过,我完全没有想法!
我目前的方法是找到过去 5 分钟内的所有结果,然后过滤结果并抓取最后 30 个条目,但这比正确的方法慢。
s = Search(using=es, index="history", doc_type=p)
.filter('range', timestamp={'gte': mins})
.extra(size=1000)
我试过了
s = Search(using=es, index="history", doc_type=p)
.sort("timestamp", {'order': "desc"})
.extra(size=30)
请您参考如下方法:
按降序对 timestamp 进行排序的正确方法是 s = s.sort('-timestamp') 或 s = s.sort( {“价格”:{“订单”:“desc”}})。
您指定的排序不正确。
