如何在 Solr 中获取最后一个索引记录? [英] How to get last indexed record in Solr?
本文介绍了如何在 Solr 中获取最后一个索引记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何在 Apache Solr 中获取/搜索最后索引的记录..?
I want to know how to get/search last indexed record in Apache Solr..?
当现有记录更新时,它会转到所有记录的末尾......所以我想获得最后一个索引记录.
When the existing record is updated then it goes to end of all the records...so I want to get that last indexed record.
谢谢..
推荐答案
您可以在 Solr 架构中添加一个时间戳"字段,以便在添加时将当前日期/时间放入记录中.
You could add a 'timestamp' field to your Solr schema that puts the current date/time into the record when it is added.
<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
然后,按此字段降序排序,第一条记录将是最新的.像这样的查询应该这样做:-
Then, do a sort in descending order by this field and the first record will be the latest one. A query like this should do it:-
http://localhost:8080/solr/core-name/select/q=*%3A*&start=0&rows=1&sort=timestamp+desc
这篇关于如何在 Solr 中获取最后一个索引记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文