开发者

Apache Solr get next & previous record in result

I have a problem when i need to fetch the next & previous document in solr index based on current document id & sort parameter.

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

is there a better work around using sol开发者_如何学运维r query to get this done?

thanks


So far i found no work around for this as theres no reference to the ordinal position of the current item in the resultset

So the temporary solution is keep the traditional way

  1. if theres completely no reference of the ordinal position (eg: come from google) fetched resultset with limited rows, use xpath to find ordinal position else fetch next set

  2. if theres reference to its ordinal position, fetch resultset from ordinal-1 to ordinal+1 with special treat on first and last

if you guys found better way to do this please share.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜