I cannot see how SolrJ and the admin UI would return different results. Could you run exactly the same query on both and show what you get here?
Upayavira On Thu, Dec 20, 2012, at 06:17 AM, 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.