views:

46

answers:

1

Right, bit of a head scratcher, although I've got a feeling there's an obvious answer and I'm just not seeing the wood for the trees.

Baiscally, using Solr as a search engine for my site, bringing back 15 results per page. When you click on a result, you get a detail page, that has a "Next in Results" link on it, which obviously forwards you on to the next result.

Whats the best way of doing this? I've come up with a few solutions but they're either too inpractical or just don't work.

I could store all the ids in a session array, then grab the one after the current one and put that in the link. But with possibly hundreds/thousands of results, the memory that array would need, and the performance hit of dealing with it isn't practical.

I could take the same approach and put it into the db, but I'll still have to deal with a potentially huge array when I grab them out of the db.

Or; I could do the search again, only returning the id's, and grab the one after the one we're currently looking at. I think this could be the best option? Although it does seem kind of messy, namely because of when I have to select the id thats on a different 'page' (ie the 16th, 31st etc result). Unless I pass through where it was in the results, and select from there, but that still doesn't seem like the right way to do it.

I'm really sorry if this is just complete nonsense, any help is massively appreciated as always,

Cheers guys!

A: 

Well your session solution is not that bad. As these thousands of results are just a few kilobytes in memory.

Although you can do it another way. you can just find out an id of the next record with simple query. that's simpler than it seems: I am sure you can find a token going next after 10cant one if you order them by numbers. For the database records just do the same ;)

Col. Shrapnel