Did a temporary workaround: Am removing the nil elements from the
search results
And subtracting the size of the nil array from the total_results.
def index
activities = []
temp = []
moduls = Modul.search(params[:search], 10, params[:page],
get_conditions_hash)
temp << moduls.delete_if{ |modul| modul.nil? }
moduls.each { |modul| activities << modul.modulable }
@activities = WillPaginate::Collection.create params[:page] || 1,
10, activities.size do |pager|
# inject the result array into the paginated collection:
pager.replace(activities)
pager.total_entries = moduls.results[:total_found] - temp.size
end
end
On Aug 8, 4:54 pm, tispratik <[email protected]> wrote:
> Hi,
>
> I see a strange behaviour, not sure if its because of Sphinx or TS.
> I have a polymorphic model called Modul. There are two modulable types
> called 'Chapter' and 'Activity'
> It is delta indexed.
>
> When i run the indexer, moduls table only contains 'Chapter'
> modulable_type entries. Two entires initially which i load through
> migrations.
>
> #Sphinx
> define_index do
> #Fields
> indexes :name, :as => :modul_name, :sortable => true
>
> #Attributes
> has "CRC32(modulable_type)", :type => :integer, :as
> => :modulable_type
> has parent_id, :as => :parent_id, :sortable => true
> has created_at, :sortable => true
> has modulable.chapter_type, :type => :integer, :as
> => :chapter_type, :sortable => true
> has modulable.objectives, :type => :integer, :as
> => :activity_objectives, :sortable => true
>
> #Turning delta index "ON"
> set_property :delta => true
> end
>
> Now when i try to get the 'Activities', it returns me an array of nil
> objects. I guess these objects are the 'Chapter' modulable type.>>
> Modul.search :with => {:modulable_type => 1426221836}
>
> => [nil, nil]
>
> TS should have returned []
>
> Regards,
> Pratik
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---