You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jonty Rhods <jo...@gmail.com> on 2011/07/21 10:41:26 UTC

previous and next rows of current record

Hi,

Is there any special query in solr to get the previous and next record of
current record.
I am getting single record detail using id from solr server. I need to get
 next and previous on detail page.

regards
Jonty

Re: previous and next rows of current record

Posted by Jonathan Rochkind <ro...@jhu.edu>.
I think maybe I know what you mean.

You have a result set generated by a query. You have an item detail page 
in your web app -- on that item detail page, you want to give 
next/previous buttons for "current search results".

If that's it, read on (although news isn't good), if that's not it, 
ignore me.

There is no good way to do it. Although it's not really so much a solr 
problem.  As far as Solr is concerned, if you know the query, and you 
know the current row into the query i, then just ask Solr for 
rows=1&start=$(i=1) to get previous, or i+1 to get next. (You can't send 
$(i-1) or $(i+1) to Solr that's just short hand, your app would have to 
calculate em and send the literals).

The problem is architecting a web app so when you are on an item detail 
page, the app knows what the "current" Solr query was, and what the "i" 
index into it was.

The app I work on wants to provide this feature too, but I am so unhappy 
with what it currently does (it is both ugly AND does not actually work 
at all right on several very common cases), that I am definitely not 
going to provide it as an example.  But if you are willing to have your 
web app send the "current" search and the index in the URL to the item 
detail page, that'd certainly make it easier.

It's not so much a Solr problem -- the answer in Solr is pretty clear. 
Keep track of what index into your results you are on, and then just ask 
for one previous or more.  But there's no great way to make a web app 
taht actually does that without horrid urls.  There's nothing built into 
Solr to help you. Solr is pretty much sessionless/stateless, it's got no 
idea what the 'current' search for your particular session is.



On 7/21/2011 2:38 PM, Bob Sandiford wrote:
> But - what is it that makes '9' the next id after '5'?  why not '6'?  Or '91238412'? or '4'?
>
> i.e. you still haven't answered the question about what 'next' and 'previous' really means...
>
> But - if you already know that '9' is the next page, why not just do another query with id '9' to get the next record?
>
> Bob Sandiford | Lead Software Engineer | SirsiDynix
> P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> www.sirsidynix.com
>
>
>> -----Original Message-----
>> From: Jonty Rhods [mailto:jonty.rhods@gmail.com]
>> Sent: Thursday, July 21, 2011 2:33 PM
>> To: solr-user@lucene.apache.org
>> Subject: Re: previous and next rows of current record
>>
>> Hi
>>
>> in my case there is no id sequence. id is generated sequence wise for
>> all category. but when we filter by category then same id become
>> random. If i m on detail page which have id 5 and nrxt id is 9 so on
>> same page my requirment is to get next id is 9.
>>
>> On Thursday, July 21, 2011, Bob Sandiford
>> <bo...@sirsidynix.com>  wrote:
>>> Well, it sort of depends on what you mean by the 'previous' and the
>> 'next' record.
>>> Do you have some type of sequencing built into your concept of your
>> solr / lucene indexes?  Do you have sequential id's?
>>> i.e. What's the use case, and what's the data available to support
>> your use case?
>>> Bob Sandiford | Lead Software Engineer | SirsiDynix
>>> P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
>>> www.sirsidynix.com
>>>
>>>> -----Original Message-----
>>>> From: Jonty Rhods [mailto:jonty.rhods@gmail.com]
>>>> Sent: Thursday, July 21, 2011 2:18 PM
>>>> To: solr-user@lucene.apache.org
>>>> Subject: Re: previous and next rows of current record
>>>>
>>>> Pls help..
>>>>
>>>> On Thursday, July 21, 2011, Jonty Rhods<jo...@gmail.com>
>> wrote:
>>>>> Hi,
>>>>>
>>>>> Is there any special query in solr to get the previous and next
>>>> record of current record.I am getting single record detail using id
>>>> from solr server. I need to get  next and previous on detail page.
>>>>> regardsJonty
>>>>>
>>>
>>>
>
>

RE: previous and next rows of current record

Posted by Bob Sandiford <bo...@sirsidynix.com>.
But - what is it that makes '9' the next id after '5'?  why not '6'?  Or '91238412'? or '4'?

i.e. you still haven't answered the question about what 'next' and 'previous' really means...

But - if you already know that '9' is the next page, why not just do another query with id '9' to get the next record?

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com


> -----Original Message-----
> From: Jonty Rhods [mailto:jonty.rhods@gmail.com]
> Sent: Thursday, July 21, 2011 2:33 PM
> To: solr-user@lucene.apache.org
> Subject: Re: previous and next rows of current record
> 
> Hi
> 
> in my case there is no id sequence. id is generated sequence wise for
> all category. but when we filter by category then same id become
> random. If i m on detail page which have id 5 and nrxt id is 9 so on
> same page my requirment is to get next id is 9.
> 
> On Thursday, July 21, 2011, Bob Sandiford
> <bo...@sirsidynix.com> wrote:
> > Well, it sort of depends on what you mean by the 'previous' and the
> 'next' record.
> >
> > Do you have some type of sequencing built into your concept of your
> solr / lucene indexes?  Do you have sequential id's?
> >
> > i.e. What's the use case, and what's the data available to support
> your use case?
> >
> > Bob Sandiford | Lead Software Engineer | SirsiDynix
> > P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> > www.sirsidynix.com
> >
> >> -----Original Message-----
> >> From: Jonty Rhods [mailto:jonty.rhods@gmail.com]
> >> Sent: Thursday, July 21, 2011 2:18 PM
> >> To: solr-user@lucene.apache.org
> >> Subject: Re: previous and next rows of current record
> >>
> >> Pls help..
> >>
> >> On Thursday, July 21, 2011, Jonty Rhods <jo...@gmail.com>
> wrote:
> >> > Hi,
> >> >
> >> > Is there any special query in solr to get the previous and next
> >> record of current record.I am getting single record detail using id
> >> from solr server. I need to get  next and previous on detail page.
> >> >
> >> > regardsJonty
> >> >
> >
> >
> >



Re: previous and next rows of current record

Posted by Jonty Rhods <jo...@gmail.com>.
Hi

in my case there is no id sequence. id is generated sequence wise for
all category. but when we filter by category then same id become
random. If i m on detail page which have id 5 and nrxt id is 9 so on
same page my requirment is to get next id is 9.

On Thursday, July 21, 2011, Bob Sandiford <bo...@sirsidynix.com> wrote:
> Well, it sort of depends on what you mean by the 'previous' and the 'next' record.
>
> Do you have some type of sequencing built into your concept of your solr / lucene indexes?  Do you have sequential id's?
>
> i.e. What's the use case, and what's the data available to support your use case?
>
> Bob Sandiford | Lead Software Engineer | SirsiDynix
> P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> www.sirsidynix.com
>
>> -----Original Message-----
>> From: Jonty Rhods [mailto:jonty.rhods@gmail.com]
>> Sent: Thursday, July 21, 2011 2:18 PM
>> To: solr-user@lucene.apache.org
>> Subject: Re: previous and next rows of current record
>>
>> Pls help..
>>
>> On Thursday, July 21, 2011, Jonty Rhods <jo...@gmail.com> wrote:
>> > Hi,
>> >
>> > Is there any special query in solr to get the previous and next
>> record of current record.I am getting single record detail using id
>> from solr server. I need to get  next and previous on detail page.
>> >
>> > regardsJonty
>> >
>
>
>

RE: previous and next rows of current record

Posted by Bob Sandiford <bo...@sirsidynix.com>.
Well, it sort of depends on what you mean by the 'previous' and the 'next' record.

Do you have some type of sequencing built into your concept of your solr / lucene indexes?  Do you have sequential id's?

i.e. What's the use case, and what's the data available to support your use case?

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com

> -----Original Message-----
> From: Jonty Rhods [mailto:jonty.rhods@gmail.com]
> Sent: Thursday, July 21, 2011 2:18 PM
> To: solr-user@lucene.apache.org
> Subject: Re: previous and next rows of current record
> 
> Pls help..
> 
> On Thursday, July 21, 2011, Jonty Rhods <jo...@gmail.com> wrote:
> > Hi,
> >
> > Is there any special query in solr to get the previous and next
> record of current record.I am getting single record detail using id
> from solr server. I need to get  next and previous on detail page.
> >
> > regardsJonty
> >



Re: previous and next rows of current record

Posted by Jonty Rhods <jo...@gmail.com>.
Pls help..

On Thursday, July 21, 2011, Jonty Rhods <jo...@gmail.com> wrote:
> Hi,
>
> Is there any special query in solr to get the previous and next record of current record.I am getting single record detail using id from solr server. I need to get  next and previous on detail page.
>
> regardsJonty
>