How to get last indexed record in Solr?

孤街浪徒 提交于 2020-01-21 03:07:35

问题


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.

thanks..


回答1:


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




回答2:


You can sort the documents by the indexed order using the following query.

http://localhost:8983/solr/select?q=*:*&sort=_docid_ asc

or 

http://localhost:8983/solr/select?q=*:*&sort=_docid_ desc


来源:https://stackoverflow.com/questions/12346240/how-to-get-last-indexed-record-in-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!