I have two columns in my db field1 and field2. I want to do fulltext search based on another field.
I need below scenario
if field2.nil?
fulltext search with field1
else
fulltext search with field2
end
model.rb
searchable do
text :field1
text :field2
boolean :check_fields do
self.field2.nil? ? false : true
end
end
controller.rb
Model.search do
fulltext keyword, :fields => :field1 if :check_fields
fulltext keyword, :fields => :field2 if :check_fields
end
I'm not getting expected results. How can I achieve condition based fulltext search.
I even tried "any do" between this two fulltext.
Can you guys please help me in getting output
This solved my problem I could directly write my condition in model.
model.rb
controller.rb