Hi Iván Somebody's emailed me about this before, off the list, so I'll cut and paste my response:
> What you want to do is a little tricky in Sphinx - you'd need to > make the query on every result page, to allow for pagination, > because if you're = searching, then there's no reliable way of > knowing what the next and previous results are, based on Sphinx's > relevance ranking, without running the query again. > > So, it could be worth caching the results - maybe via memcached? - > but then you're also going to hit issues if the user is running > multiple searches in different tabs. One approach could be to run a > search_for_ids query on every page - so you're not instantiating the > full ActiveRecord objects each time - and use those ids to point to > the previous and next results. Continuing those thoughts... If you were to put the search results into the session, you'd want to give each search a unique identifier, to allow for a single user paging through multiple searches at once via several tabs. Keep in mind that there's pagination in each search result set though, so if the user gets to item 20 (if there was 20 items per page), then the next is going to be in the following page, so you'll need to allow for that as well. If you find a neat way of managing all this, please let us know :) Good luck! -- Pat On 16/04/2009, at 2:49 PM, Iván Belmonte wrote: > > Hello there again > > My app does searchs on products and makes a list with the results. I > paginate them in 10 results per page, and users can click an item to > show it. > Well, the CEO's of this project want users to be able to browse > results one by one. > > I mean: > > 1) you search "hello this is sample search string" > 2) you get 20 pages of results > 3) on page 3, you click an item > 4) it shows you a page with the item details > 5) here they want a "previous" and a "next" button, for browsing items > one by one without going back to the list > > I'm not sure of the best way to do it, but I've thought to save a > session variable including all the item id's so I can read previous > and next items from the array. Is it a good idea? > If it is, how can I access the whole array of id's coming from sphinx > after the "Search" call? > > Thanx in advance! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---
