简体   繁体   中英

Multiple Keyword Search Using Thinking Sphinx Rails Plugin

I'm using the sphinx search engine with the thinking sphinx plugin for rails.

I have a job model with a title attribute that is indexed by sphinx. I'd like to search across multiple jobs and capture any that match 1 or more keywords.

For instance...

Job.search("rails, django, symfony")

...and get an array of job objects with the following titles "rails developer for hire", "looking for a django wizard", "anyone know symfony?"

I have these three separate jobs stored and indexed in my database. When I run the above search i get an empty array. Each job is found when a single query term is provided on its own.

I would rather not do this Job.search "rails" Job.search "django" Job.search "symfony"

Does anyone know how to pass multiple keywords to the sphinx search engine?

Job.search("rails | django | symfony", :match_mode => :extended) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM