Ok, I solved my problem my applying the offset by hand. In case it
helps someone, here's my solution:

ids = search_for_ids(query, :with => with, :limit => (offset + limit)
* [limit,20].max)
# 1. filter with secure
secure_ids = Zena::Db.fetch_ids("SELECT id FROM nodes WHERE id IN
(#{ids.join(',')}) AND #{secure_scope('nodes')}")
# 2. reorder and apply offset
if secure_ids = (ids & secure_ids)[offset..(offset + limit - 1)]
  # 3. populate
  records = Node.find(:all, :conditions => {:id => secure_ids})
  # 4. reorder
  secure_ids.map {|id| records.detect {|r| r.id == id }}
else
  []
end

And sorry for the spam.... :-)

Gaspard

On Wed, Nov 4, 2009 at 9:44 AM, Gaspard Bucher <[email protected]> wrote:
> Damn ! Relevance ordering no longer works with an sql_offset. I'll
> adapt my patch, please ignore the pull request.
>
> On Wed, Nov 4, 2009 at 9:13 AM, Gaspard Bucher <[email protected]> wrote:
>> Hi there !
>>
>> I have just sent a pull request for a patch that enables sql_offset
>> and sql_limit to offset/limit during the population phase.
>>
>> Let me explain my use case:
>>
>> The sphinx search can return many records that are not actually
>> readable by the current visitor (no access right). These records will
>> therefore be filtered out during the population phase and applying a
>> simple "compact" solves the problem except for the pagination which
>> becomes quite wrong (but that's not the main issue here since there is
>> a solution by applying "paginate" after compact).
>>
>> The problem is related to "pseudo-ids". Everywhere a user would be
>> expected to enter an id (to set the parent_id, a relation, insert an
>> image with textile, internal link), she can enter a "pseudo-id":
>>
>> Id version:
>>
>> "":45  --> link to page 45 using the page's title as text
>>
>> Pseudo-id version:
>>
>> ""::bird++ --> link to the *third* page matching 'bird'
>>
>> Since the user has a live preview of the link, it is easy to just keep
>> adding '+' until the right page is found.
>>
>> In order to enable this with Sphinx searching, both sql_offset and
>> sql_limit are needed.
>>
>> Gaspard
>>
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to