Friday, 15 March 2013

ruby on rails - solr sunspot fulltext search based on boolean field -



ruby on rails - solr sunspot fulltext search based on boolean field -

i have 2 columns in db field1 , field2. want fulltext search based on field.

i need below scenario

if field2.nil? fulltext search field1 else fulltext search field2 end

model.rb

searchable text :field1 text :field2 boolean :check_fields self.field2.nil? ? false : true end end

controller.rb

model.search fulltext keyword, :fields => :field1 if :check_fields fulltext keyword, :fields => :field2 if :check_fields end

i'm not getting expected results. how can accomplish status based fulltext search.

i tried "any do" between 2 fulltext.

can guys please help me in getting output

this solved problem straight write status in model.

model.rb

searchable text :field1 text :searchable_field field2.nil? ? field1 : field2 end end

controller.rb

model.search fulltext keyword, :fields => :searchable_field end

ruby-on-rails ruby solr full-text-search sunspot

No comments:

Post a Comment