Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Robust search with Searchkick
Search
Nando Sousa
May 16, 2015
Technology
80
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Robust search with Searchkick
Minitalk about Searchkick gem
Nando Sousa
May 16, 2015
More Decks by Nando Sousa
See All by Nando Sousa
Metaprogramming in Elixir
nandosousafr
0
280
Yet another introduction to concurrency
nandosousafr
4
230
Tirando Proveito das Rails Engines
nandosousafr
0
120
5 basic tips for RubyOnRails projects
nandosousafr
1
460
Workshop Git para o DevInSanta meetup.
nandosousafr
0
77
Other Decks in Technology
See All in Technology
会社紹介資料 / Sansan Company Profile
sansan33
PRO
24
430k
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
260
モダンフロントエンド 開発研修
recruitengineers
PRO
4
740
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
SmartHR Engineering Team Deck
smarthr
1
2.3k
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
3
25k
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
340
Bits Agent Builder の⼊⾨と活⽤事例
nulabinc
PRO
0
170
猫付きpingコマンドを自作
uyuki234
0
250
My broken English still works: speaking at global OSS events
naruoga
0
110
システム思考で問題に対処する
yussak
0
320
ブラウザ研修 2026
recruitengineers
PRO
6
1.1k
Featured
See All Featured
Bash Introduction
62gerente
615
220k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Docker and Python
trallard
47
4.1k
A Tale of Four Properties
chriscoyier
163
24k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
920
Marketing to machines
jonoalderson
1
5.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Paper Plane (Part 1)
katiecoart
PRO
1
10k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
searchkick
• Full Stack Developer at Resultados Digitais • @nandosousafr on
twitter • Marketing B.I team • shipit.resultadosdigitais.com.br
Problem Itunes search sucks!
scheme name string description text podcasts title string show_notes text
podcast_id integer episodes
$ brew install elasticsearch Searchkick requires elasticsearch
Gemfile gem 'searchkick' $ bundle install
app/models/episode.rb class Episode < ActiveRecord::Base belongs_to :podcast end searchkick Automatically
adds callbacks after_commit :reindex
$ bundle exec rake searchkick:reindex:all Indexing $ bundle exec rake
searchkick:reindex CLASS=Episode Episode.reindex
class SearchController < ApplicationController def index end end @episodes =
Episode.search term, includes: :podcast term = params[:q].presence || '*' eager loading app/controllers/search_controller.rb
Problem solved!
Highlights
class Episode < ActiveRecord::Base searchkick end app/models/episode.rb highlight: [:show_notes] $
bundle exec rake searchkick:reindex CLASS=Episode reindex
app/controllers/search_controller.rb class SearchController < ApplicationController def index term = params[:q].presence
|| '*' @episodes = Episode.search term, search_options end protected def search_options end end { includes: :podcast, highlight: { tag: '<strong>', fields: { show_notes: { fragment_size: 300 } } } }
So much better!
title must be stronger than show notes
Boosting fields
def search_options { includes: :podcast, highlight: { tag: '<strong>', fields:
{ show_notes: { fragment_size: 300 } } }, } end Boost and sort fields: ['title^10', 'show_notes^5'], order: { _score: :desc, release_date: :desc }
None
Facets
None
None
Quick tips
Asynchronous reindex class Episode < ActiveRecord::Base # ActiveJob required searchkick
callbacks: :async # Disable callbacks searchkick callbacks: false end
Personalized Results class Episode < ActiveRecord::Base has_many :users def search_data
attributes.merge( favorited_by: users.pluck(:id) ) end end # SearchController Episode.search 'Rails', boost_where: { favorited_by: current_user.id }
OpenSource http://podaholic.com
[email protected]
@nandosousafr We’re hiring! resultadosdigitais.com.br/trabalhe-conosco/