问题
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