Saturday, March 24, 2018

Rails: Full-Text Search related

Pg_Search & SearchKick are gems 

Pg_Search vs SearchKick
https://www.webascender.com/blog/rails-search-gems-searchkick-vs-pg_search/

Pg_Search

One of the best features of Postgres is the built-in, full-text search capabilities. The pg_search gem helps maximize these capabilities by providing a powerful, yet simple, search capability. pg_search is great for a basic search that will search multiple models, associations, and is able to hook into advanced Postgres features in the optional contrib package. This contrib package allows fuzzy and trigram searching.

ElasticSearch & SearchKick in Depth
https://www.webascender.com/blog/rails-elasticsearch-searchkick-depth/

SearchKick:
Github: https://github.com/ankane/searchkick
GoRails video: https://gorails.com/episodes/elasticsearch-with-searckick
DriftingRuby video: https://www.driftingruby.com/episodes/searchkick-and-elasticsearch

Other videos related to Search:
- Ruby on Rails - Railscasts #278 Search With Sunspot - https://www.youtube.com/watch?v=6ub9OYNvHZk
- Ruby on Rails - Railscasts PRO #343 Full-Text Search in PostgreSQL (pro) - https://www.youtube.com/watch?v=n41F29Qln5E
- RailsConf 2016 - Multi-table Full Text Search with Postgres By Caleb Thompson - https://www.youtube.com/watch?v=OzHhJPlgZaw


Rails: Best practices for running Rails in production

ActiveRecord related: marginalia gem - for adding comments to ActiveRecord queries

https://signalvnoise.com/posts/3130-tech-note-mysql-query-comments-in-rails
From https://github.com/basecamp/marginalia:
Attach comments to your ActiveRecord queries. By default, it adds the application, controller, and action names as a comment at the end of each query.
This helps when searching log files for queries, and seeing where slow queries came from.
For example, once enabled, your logs will look like:
Account Load (0.3ms)  SELECT `accounts`.* FROM `accounts` 
WHERE `accounts`.`queenbee_id` = 1234567890 
LIMIT 1 
/*application:BCX,controller:project_imports,action:show*/
You can also use these query comments along with a tool like pt-query-digest to automate identification of controllers and actions that are hotspots for slow queries.
......
.......
Marginalia ships with :application, :controller, and :action enabled by default. In addition, implementation is provided for:
  • :line (for file and line number calling query). :line supports a configuration by setting a regexp in Marginalia::Comment.lines_to_ignore to exclude parts of the stacktrace from inclusion in the line comment.
  • :controller_with_namespace to include the full classname (including namespace) of the controller.
  • :job to include the classname of the ActiveJob being performed.
  • :hostname to include Socket.gethostname.
  • :pid to include current process id.

Followers

Blog Archive