The only sure way to get the last searchable document is to use a
timestamp or sequence number in the document. I do not think that using
a timestamp with default=NOW will give a unique timestamp, so you need
your own sequence number.
On 12/19/2012 10:17 PM, Joe wrote:
I'm using SOLR 4 for an application, where I need to search the index soon
after inserting records.
I'm using the solrj code below to get the last ID in the index. However, I
noticed that the last id I see when I execute a query through the solr web
admin is often lagging behind this. And that my searches are not including
all documents up until the last ID I get from the code snippet below. I'm
guessing this is because of delays in hard commits. I don't need to switch
to soft commits yet. I just want to make sure that I get the ID of the last
searchable document. Is this possible to do?
SolrQuery query = new SolrQuery();
query.set("qt","/select");
query.setQuery( "*:*" );
query.setFields("id");
query.set("rows","1");
query.set("sort","id desc");
QueryResponse rsp = m_Server.query( query );
SolrDocumentList docs = rsp.getResults();
SolrDocument doc = docs.get(0);
long id = (Long) doc.getFieldValue("id");
--
View this message in context:
http://lucene.472066.n3.nabble.com/Finding-the-last-committed-record-in-SOLR-4-tp4028235.html
Sent from the Solr - User mailing list archive at Nabble.com.