How can i search full text with sentence and search any word matched or different configuration
example:
"professor john smith" is searching in model title
it have to display result which matched the "proffessor john smith", "professor john" ", "proffesson smith"
There are lots of fulltext search technologies supports rails. elasticsearch and solar search ar eone of them
Rails cast about integrating solar search is here
There are some technologies compatible with rails. For example sunspot, as @scottxu wrote, or elasticsearch, as @knotito said. Good solution also - sphinx (fast and lite) and thinking_sphinx gem. If you use postgresql as database, and you do not want use external solutions - you can choose pg_search gem, that emplements fulltext search with pg technologies only. I prefer elasticsearch, but it requires JVM, and some people don't like this.
updated:
how to use pg_search: First, you should add pg_search to gemfile, make bundle install
, and add to your model something like:
include PgSearch
pg_search_scope :search_by_title, :against => :title
if you didn't do it before.
After, you can try to test it in rails console: Professor.search_by_title('professor smith')
For fulltext searches you can use Elasticsearch
To implement that you can follow this railscast
you can use sunspot
description: Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine. Sunspot is built on top of the RSolr library, which provides a low-level interface for Solr interaction; Sunspot provides a simple, intuitive, expressive DSL backed by powerful features for indexing objects and searching for them.
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.