title: Apache Solr get next & previous record in result
body: <p>I have a problem when i need to fetch the next &amp; previous document in solr index based on current document id &amp; sort parameter.</p>
  
  <pre><code>do while true
   fetch 500 index based on sort
   use xpath to find current id in resultset
   if found
    previous = preceding-sibling
    next = following-sibling
    break
   else
     if numfound == amount of fetched document
       break
     else
       amount += 500
       next loop
     /if
   /if    
  /do
  </code></pre>
  
  <p>is there a better work around using solr query to get this done?</p>
  
  <p>thanks</p>