Full-text search of ruby on rails

Source: Internet
Author: User
Tags ruby on rails

Finally, the full-text search of ferret was completed. It was not easy to get three full-text searches.

The last two times on my mac, ferret has been confused. The main problem is that it cannot be used for Chinese word segmentation, and it is always crash. I suspect that macos is not very well supported, directly on the server (centos.

Finally, we got it done on the server.

Note: When debugging, disable ferrect-browse, which will prevent reregister class and invalidate some of your updates.

The reason why I haven't done it all the time is that the new api is different from the old one, so I haven't successfully specified customized analyzer. It's too faint. There are almost no examples or articles on the Internet about the new api call method, they are all old, only the latest rdoc.

Another error today is that fields writes field (as if it was copied from the Internet), so the content sometimes can index and sometimes cannot index, and later found that the newly written test code uses filed, the old one is right.

During the test, you must restart ferret_server and then mongrel. Since the ferrect server does not restart register index after startup, it may be registered when mongrel calls act_as_ferrect at startup, but it seems that the ferrect server in the log will know what model you regiester has and how it does it.

 

Server installation process,

Su-

Gem install ferret

Gem install acts_as_ferret

Run aaf_install in your project directory. If the command cannot be found, run/usr/local/bin/aaf_install.

In this way, the installation is complete, and no other installation is required.

In addition, you must install the word segmentation module rmmseg.

Gem install rmmseg

Test

> Echo "we all like Ruby" | rmmseg

> We all like Ruby.

Configure config/ferrect_server.yml

Add require 'acts _ as_ferret 'to environment. RB'

Add a statement to the model for Index

Class Doc

# Use rmmseg

Ranalyzer = rmmseg: ferret: analyzer. New {| tokenizer |

Ferret: Analysis: lowercasefilter. New (tokenizer)

}

Acts_as_ferret: remote => true,: fields => [: title,: content],: ferret => {: analyzer => ranalyzer} Because content is not a data field, so add method def content # loadContent... end

 

 

Resources and Lin

 

Ferrect

Http://www.davebalmain.com/trac/wiki/FerretOnRails

Act_as_ferret

Http://rm.jkraemer.net/wiki/aaf

Rmmseg

Http://rmmseg.rubyforge.org/

Rdoc

Http://code.jkraemer.net/rdoc/acts_as_ferret/

 

 

 

This article is created by happy writers

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.