0

i am developing a job portal using rails 4. i have search box where job seeker can search jobs. currently i am able to do it for job title and description , as follows

scope :by_name_or_desc,lambda{|search| where(" title ilike (?) or description ilike(?)","%#{search}%","%#{search}%") if search.present?}

i want to use the same search box for skills also where seeker can search job using skill. i have skill_ids as a column in my Job model . which is array field. how can i modify above query to do the same.

i also tried doing this ,

scope :by_name_or_desc,lambda{|search| where(" title ilike (?) or description ilike(?) or '#{search}' = ANY (skill_ids)","%#{search}%","%#{search}%") if search.present?}
1

1 Answer 1

1

If you use PostgreSQL, you should take a look at Full Text Search feature. Otherwise i recommend you to use Elastic Search or Sphinx for this kind of stuff. Full-text search is not what RDBMS designed for. With project's growth your approach will be only a headache.

1
  • elastic search is the better option
    – kali
    Commented Apr 7, 2015 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.