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
0
76
Robust search with Searchkick
Minitalk about Searchkick gem
Nando Sousa
May 16, 2015
Tweet
Share
More Decks by Nando Sousa
See All by Nando Sousa
Metaprogramming in Elixir
nandosousafr
0
270
Yet another introduction to concurrency
nandosousafr
4
220
Tirando Proveito das Rails Engines
nandosousafr
0
97
5 basic tips for RubyOnRails projects
nandosousafr
1
420
Workshop Git para o DevInSanta meetup.
nandosousafr
0
74
Other Decks in Technology
See All in Technology
AI駆動開発を事業のコアに置く
tasukuonizawa
1
280
AWS Network Firewall Proxyを触ってみた
nagisa53
1
240
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.5k
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
320
Amazon Bedrock Knowledge Basesチャンキング解説!
aoinoguchi
0
150
生成AIを活用した音声文字起こしシステムの2つの構築パターンについて
miu_crescent
PRO
3
210
Agile Leadership Summit Keynote 2026
m_seki
1
650
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
160
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
440
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.5k
AIエージェントに必要なのはデータではなく文脈だった/ai-agent-context-graph-mybest
jonnojun
0
120
Webhook best practices for rock solid and resilient deployments
glaforge
2
300
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
920
We Have a Design System, Now What?
morganepeng
54
8k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
Done Done
chrislema
186
16k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
52
The untapped power of vector embeddings
frankvandijk
1
1.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
Into the Great Unknown - MozCon
thekraken
40
2.3k
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/