Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Robust search with Searchkick
Search
Nando Sousa
May 16, 2015
Technology
87
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
Transcript
26 slides
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/
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
130
5 basic tips for RubyOnRails projects
nandosousafr
1
470
Workshop Git para o DevInSanta meetup.
nandosousafr
0
80
Other Decks in Technology
See All in Technology
認知負荷の減らし方 ~開発にも日常業務にも活かせるノウハウ~
minorun365
PRO
20
20k
AIフレンドリーなGenerative UIをJSXで
uhyo
2
1.1k
AIエージェントのアーキテクチャ設計
nsatoh
0
610
Claude Certified Developer – Professional 試験対策
shinoisa
0
300
Kiro Crew の Conductor mode: 1 つのチャットに渡したゴールを、コンダクターがワーカーに分けて任せる
inariku
PRO
1
150
New Relicのアラート対応をClaude Codeで自動修正するワークフローを作った話
manabuseki
3
760
AI時代に問い直す「プロダクションミーティング」の価値 〜チームでサービスの信頼性を高める取り組み〜
mackerelio
0
210
テスト自動化の先、テスト自律化に向けて
mineo_matsuya
3
1.3k
統制されたID・権限をどう利用するか : DPoP/FAPIによるAPIセキュリティ強化
oidfj
2
370
コーディングできない僕にBobが舞い降りた
shumpei3
0
240
PR 生成AIガバナンスの全体像がわかる本
yoshimura_datam
0
140
[DBRE Summit 26] DBRE はデータベース運用をどう変えたのか
_awache
0
160
Featured
See All Featured
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
590
Agile that works and the tools we love
rasmusluckow
331
22k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
Mobile First: as difficult as doing things right
swwweet
225
10k
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
3
190
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
710
Embracing the Ebb and Flow
colly
88
5.2k
Deep Space Network (abreviated)
tonyrice
0
430
Highjacked: Video Game Concept Design
rkendrick25
PRO
2
600
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k