# Linking to the paginated items from search results

**URL:** <https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028>\
**Category:** Rails\
**Created:** [August 2, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028 "2006-08-02T23:51:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [August 2, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028/1 "2006-08-02T23:51:23Z")

</div>

Using Ferret for searching, I’ve got results that I need to link to.  
Which is fine, except for that they’re displayed on paginated pages  
using Rails paginate function - so it’s not like I can’t get it from the  
database or anything else. Anyone have any ideas on how to go about  
this? It’s not so much a coding problem as a theory problem, and I can’t  
even think of how to begin. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [August 3, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028/2 "2006-08-03T14:23:21Z")

</div>

I think there are really only two options:

1. Store the search results in the session.

2. Use ferret’s :num\_docs and :first\_doc to paginate the results for  
each page. NOTE: These options are going to change to :limit and  
:offset to be more railish in a future ferret release.

I am currently doing option 2 on my site. However, I asked a similar  
question to this group a while back and one of the interesting points  
someone made was that when you search through results it can be  
annoying if they shift around, so in that case option 1 would be  
preferred.

Good Luck,  
Tom

On 8/2/06, Adrian F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Tom D.

[http://atomgiant.com](http://atomgiant.com)  
[http://gifthat.com](http://gifthat.com)

---

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [August 3, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028/3 "2006-08-03T14:23:29Z")

</div>

On 8/3/06, Tom D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> someone made was that when you search through results it can be  
> annoying if they shift around, so in that case option 1 would be  
> preferred.
> 
> Good Luck,  
> Tom

Hi Tom,

Just curious. What do you mean when you say the results shift around?  
Is this something I need to fix in Ferret?

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [August 3, 2006, 10:08pm UTC](https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028/4 "2006-08-03T22:08:06Z")

</div>

Hi Dave,

Actually, I meant if you rerun the query between page requests and the  
index changes then your search results may legitimately be different.

For example if someone is sorting on created\_at DESC and any entries  
get added in between pages then some of thre results that were just  
show on say page 1 will now be in page 2 since those new entries will  
be returned as well.

If that doesn’t make sense, let me know and I’ll try again. For some  
reason I found it very difficult to type that out in words 🙂

Tom

On 8/2/06, David B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > question to this group a while back and one of the interesting points  
> > Is this something I need to fix in Ferret?
> 
> Cheers,  
> Dave
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Tom D.

[http://atomgiant.com](http://atomgiant.com)  
[http://gifthat.com](http://gifthat.com)

---

<div class="post-metadata">

**Author:** ![adrian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@adrian](https://www.ruby-forum.com/u/adrian)\
**Post date:** [August 4, 2006, 3:55am UTC](https://www.ruby-forum.com/t/linking-to-the-paginated-items-from-search-results/101028/5 "2006-08-04T03:55:02Z")

</div>

On 8/4/06, Tom D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If that doesn’t make sense, let me know and I’ll try again. For some  
> reason I found it very difficult to type that out in words 🙂
> 
> Tom

Thanks Tom. I understand perfectly.
