Here's the way to do it, based on Alexandre's idea:

Write a PostFilter which takes in a document id. It lets through all
documents until it sees that document id. Once it sees it, it stops
letting them through.

Thus, the total count of documents would be the position of your queried
car.

Then, you do a q=make:toyota&fq={!mypostfilter id=12345}&rows=0

This simply tells Solr to return a numFound value (your required
position) whilst ignoring the actual documents themselves.

This would, I reckon, be as performant as a search for q=make:toyota and
wouldn't require too much coding.

Upayavira
 
On Thu, Sep 3, 2015, at 05:28 PM, Alexandre Rafalovitch wrote:
> So, basically for each car, you want to generate a query with the same
> parameter (e.g. make) and then say where in the results for that
> query, your particular car would be. Right?
> 
> I think the only way is to run the query and to see where the car is
> in the result. So, a custom code of some sort. But you don't have to
> do it in the Client.
> 
> You could do it in a Solr PostFilter and basically do the count there
> and just not return anything while - somehow - injecting the count
> into the results (maybe via custom search module).
> http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/search/PostFilter.html
> 
> Or maybe in a custom search module, though I suspect that's harder and
> more expensive.
> 
> Or enable lazy-loading and request only Id fields to make it cheaper
> to iterate through larger query on the client (possibly with a cursor
> mark).
> 
> Hope some of these help.
> 
> Regards,
>    Alex.
> ----
> Solr Analyzers, Tokenizers, Filters, URPs and even a newsletter:
> http://www.solr-start.com/
> 
> 
> On 3 September 2015 at 11:57, Erick Erickson <erickerick...@gmail.com>
> wrote:
> > OK, but how are they ordered on the public pages? I'm guessing
> > that what I'm missing here is something like
> > "If I did an identical search on the public pages, my car would be
> > number 208" _Something_ has to glue the two separate pages
> > together.
> >
> > If it's something like that I don't see a good way to handle it. The
> > position of the member's car on the public page sounds like
> > it changes by query, i.e. if the search is "blue chevy" cars then
> > the position would be different than just "chevy".
> >
> > Even if it were a static ranking, by the time you tried to make static
> > lists for all the combinations it'd be a nightmare if it was do-able at
> > all.
> >
> > Don't see a clean way to do this off the top of my head.
> >
> > Best,
> > Erick
> >
> > On Wed, Sep 2, 2015 at 11:44 PM, Shayan Haque <m...@shyyawn.com> wrote:
> >> Let me give an example: for suppose we have "public pages" which list cars
> >> for makes (they use  q=make:Chery  or   q=make:Toyota etc...) and list cars
> >> for all members.
> >>
> >> Now suppose, in our member account area, there is already a page that lists
> >> cars that the current logged in member had posted. In this listing, we'd
> >> like to add, that where on the public pages his published cars shows. So if
> >> a member posted a Toyota Car or Honda Car, it should show your posted
> >> Toyota Car 1 is shown on 208th 'position' on public page  /toyota/. The
> >> public page shows 10 cars per page so that would make it the 21st page but
> >> page number is easy to calculate if the position is know.
> >>
> >> Hope this clears it a bit.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Sep 3, 2015 at 1:39 PM Erick Erickson <erickerick...@gmail.com>
> >> wrote:
> >>
> >>> It's entirely unclear what you mean by "position".
> >>>
> >>> bq:  where for "make and model" his
> >>> first result comes
> >>>
> >>> Comes in what? The search result list? Some
> >>> a-priori ordering of all the cars that has
> >>> nothing to do with this search? The results
> >>> list of everyone's cars that have the same
> >>> make and model? If this latter, what good
> >>> is this doing the user? On what criteria
> >>> are the make/model combination ordered so
> >>> that the position of the user's car has
> >>> meaning?
> >>>
> >>>  Some concrete examples would help I think.
> >>>
> >>> Best,
> >>> Erick
> >>>
> >>>
> >>> On Wed, Sep 2, 2015 at 9:42 PM, Shayan Haque <m...@shyyawn.com> wrote:
> >>> > Thanks for the reply Erick.
> >>> >
> >>> > How do I get the position? I am searching on e.g. car model and make,
> >>> and I
> >>> > want to show on which position the members's first car falls for that
> >>> > specific car model and make. So I tell solr, get listing for the cars
> >>> with
> >>> > the model and make. I want from that result, if the member's first 
> >>> > result
> >>> > is 208th document, could be 2008th.
> >>> >
> >>> > Well the web interface that I need to implement is different though. In
> >>> > actual the member will see all his cars with where for "make and model"
> >>> his
> >>> > first result comes. If I get the above thing to work, I'd basically
> >>> search
> >>> > solr for each of his car's make and model. It will be 12 or 24 cars per
> >>> > page, so it's not the best solution but still better if solr can give 
> >>> > the
> >>> > position. Alternate would be to I have to loop all the results pr solr
> >>> > search, that would be even worse, 12 * 10000+ results. I may even have
> >>> > limit the search to 1000 positions per make and model or some other cap
> >>> and
> >>> > show user not the exact position if not found in the 1000 result.
> >>> >
> >>> >
> >>> > Maybe I am not thinking in the right direction using Solr for this. 
> >>> > Can't
> >>> > think how I'd get the position any other way as the site's public pages
> >>> use
> >>> > solr for listing.
> >>> >
> >>> >
> >>> >
> >>> > -
> >>> > Regards,
> >>> > Shayan
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > On Thu, Sep 3, 2015 at 12:08 PM Erick Erickson <erickerick...@gmail.com>
> >>> > wrote:
> >>> >
> >>> >> Well, you have access to the start parameter, isn't it just
> >>> >> start+(ordinal position in the page)?
> >>> >>
> >>> >> Best,
> >>> >> Erick
> >>> >>
> >>> >> On Wed, Sep 2, 2015 at 7:01 PM, Shayan Haque <m...@shyyawn.com> wrote:
> >>> >> > Hi,
> >>> >> >
> >>> >> > I need to get a document position within a search result for a
> >>> specific
> >>> >> > member, to show them where there result lie for a particular set of
> >>> >> > filters... I tried using a Solr-Ranking plugin but its outdated,
> >>> version
> >>> >> > 3.5 compatible. Is there some other way?
> >>> >> > Ordinal ranking or any other thing.. the version I am using is solr
> >>> 4.7.
> >>> >> > The last resort would be counting in the app.. but the issue is that
> >>> >> would
> >>> >> > be extensive... it would mean running a Solr request for each listed
> >>> item
> >>> >> > to get its position by looping through the results till X page or X
> >>> limit
> >>> >> > ... can't traverse all data.
> >>> >> >
> >>> >> > Help plz.
> >>> >> >
> >>> >> >
> >>> >> > -Shayan
> >>> >>
> >>>
> >> --
> >>
> >> Kind Regards,
> >> Shayan

Reply via email to