Adds PostgreSQL full-text search capabilities to ActiveRecord models with named scopes and multi-model search.
PgSearch is a Ruby gem that builds ActiveRecord named scopes to leverage PostgreSQL's full-text search capabilities. It allows Rails developers to implement advanced search features directly within their models using PostgreSQL's native search functions, eliminating the need for external search services. The gem supports multiple search algorithms including tsearch, trigram, and dmetaphone for flexible text matching.
Rails developers building applications with PostgreSQL who need integrated, database-native search functionality without external dependencies. Particularly useful for projects requiring multi-model search, fuzzy matching, or complex search scopes.
Developers choose PgSearch because it provides a seamless ActiveRecord interface to PostgreSQL's powerful search features, reducing infrastructure complexity while maintaining performance. Its multi-search capability and support for various search algorithms offer flexibility that standalone search gems often lack.
pg_search builds ActiveRecord named scopes that take advantage of PostgreSQL’s full text search
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Directly leverages PostgreSQL's full-text, trigram, and dmetaphone search algorithms, eliminating external dependencies while maintaining Rails conventions.
Supports advanced features like weighting, ranking, and association search through customizable named scopes, as shown in the README's examples for multi-column and dynamic searches.
Enables unified search across different ActiveRecord models via a single pg_search_documents table, ideal for building site-wide search pages without external services.
Allows use of precomputed tsvector columns for faster searches, though the README notes this requires manual trigger setup and indexing.
Advanced features like trigram and dmetaphone require installing PostgreSQL extensions (e.g., pg_trgm, fuzzystrmatch), and tsvector columns need custom triggers, adding setup complexity.
Multi-search relies on Active Record callbacks for indexing; methods like update_all can bypass these, leading to stale data unless manually rebuilt with tasks like PgSearch::Multisearch.rebuild.
Out-of-the-box performance may lag for large datasets, as optimizing often requires extra steps like creating tsvector columns and indexes, which aren't automated.