How to get last Document insert in Solr?

烂漫一生 提交于 2019-12-12 22:58:01

问题


My Problem is..

when I want to get last Document ID in Solr I get 99999999 and last Id = 246458031

I try this How to get last indexed record in Solr?

and only work if last ID <= 99999999

2.and when I use timestamp many record have the same date [timestamp": "2017-08-14T08:51:21.185Z]

So I need way to get Last Id from Solr

EDIT

I found Solution [q=*:*&start=0&rows=1&sort=timestamp+desc,id+desc] I Sorted by time & ID and it's working So Good


回答1:


I found Solution

[q=:&start=0&rows=1&sort=timestamp+desc,id+desc] I Sorted by time & ID and it's working So Good




回答2:


You can sort by _version_ field in descending order. AFAIK, _version_ field is a epoch timestamp (of when the document was indexed into Solr) in milliseconds multiplied by 2^20.

Relevant code snipped from Solr codebase:

public long getNewClock() {
  synchronized (clockSync) {
    long time = System.currentTimeMillis();
    long result = time << 20;
    if (result <= vclock) {
      result = vclock + 1;
    }
    vclock = result;
    return vclock;
  }
}


来源:https://stackoverflow.com/questions/45671144/how-to-get-last-document-insert-in-solr

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