mardi 23 mai 2017

popularity is not a multiple-value field, so it cannot index values [0.0]

Hi Have a model named CustomContent with searchable block named popularity

integer :popularity do
  ContentStat.where(content_id: self.content_id, content_type: self.content_type).pluck(:popularity)
end

When tried to create custom_content it is throwing me an error

ArgumentError - popularity is not a multiple-value field, so it cannot index values [0.0]: sunspot (2.2.0) lib/sunspot/field.rb:41:in to_indexed' sunspot (2.2.0) lib/sunspot/field_factory.rb:59:inpopulate_document' sunspot (2.2.0) lib/sunspot/indexer.rb:100:in block in prepare' sunspot (2.2.0) lib/sunspot/indexer.rb:99:inprepare' sunspot (2.2.0) lib/sunspot/indexer.rb:25:in block in add' sunspot (2.2.0) lib/sunspot/indexer.rb:25:inadd' sunspot (2.2.0) lib/sunspot/session.rb:91:in index' sunspot (2.2.0) lib/sunspot/session_proxy/abstract_session_proxy.rb:11:inindex' sunspot (2.2.0) lib/sunspot.rb:184:in `index'

I have done something like below

integer :popularity, :references => ContentStat, :multiple => true do
  ContentStat.where(content_id: self.content_id, content_type: self.content_type).pluck(:popularity)
end

Since I am using this Popularity block for sorting purpose,I can't use multiple true, It's throwing me error saying multi valued block can't be used for sorting

Help me with it

Aucun commentaire:

Enregistrer un commentaire