Implementing a Basic Fuzzy Search with Rails

As we mentioned in Introduction, Shine will be sharing a database with an existing customer-facing application. The customer-search feature we’re building will search one of the tables in that database.

In the real-world, our database would already exist and we’d hook up to it directly. Since that’s not the case, we’ll need to simulate its existence by creating the table in Shine’s database. And, because we’ll use Postgres query performance optimization, our table is going to need a lot of data in it.

Setting Up the New Table and Data

If we were using an existing table, we wouldn’t need a migration—we could just create the Customer model and be done. That’s not the case (since this is an example ...

Get Rails, Angular, Postgres, and Bootstrap now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.