dougal / acts_as_indexed

Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app
http://douglasfshearer.com/blog/rails-plugin-acts_as_indexed
MIT License
211 stars 49 forks source link

How does it work with just a few characters in search string? #60

Closed szymon33 closed 7 years ago

szymon33 commented 7 years ago

I use in my app:

acts_as_indexed fields: [:name]

Assuming the follwoing product name "Uniwersalna pokrywka Stoneline"

The following expression will find the record:

Product.with_query('Uniwe')

Below expression will NOT find anything. Just one character less though.

Product.with_query('Uniw')

why?

dougal commented 7 years ago

min_word_size is meant as a configuration option to prevent abuse. With min_word_size set to 1, a query of U would match the letter U on it's own, but not Uniwe.

A prefix query, ^Uniwe, will match Uniwersalna even at the default min_word_size of 3.

szymon33 commented 7 years ago

Thank you very much @dougal for your prompt reply. You are right. But how about searching inside text with search string i. ex. 'sal' ?

dougal commented 7 years ago

No problem.

There is no support for mid-atom matching.

The index is broken up into groups of atoms, in directories by their prefix. It is only efficient to search for either entire atoms, or prefixes.

szymon33 commented 7 years ago

That is exactly what I need. Thanks and wish you a Happy New Year!