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
56
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
260
Yet another introduction to concurrency
nandosousafr
4
170
Tirando Proveito das Rails Engines
nandosousafr
0
76
5 basic tips for RubyOnRails projects
nandosousafr
1
310
Workshop Git para o DevInSanta meetup.
nandosousafr
0
67
Other Decks in Technology
See All in Technology
社内勉強会運営のコツ
senoo
6
1.2k
マルチアカウント環境への発見的統制の導入
ch1aki
1
1.3k
Autonomous Database Cloud 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
14
35k
継続的な改善 x ⾮連続的な進化
sansantech
PRO
3
100
オブザーバビリティの Primary Signals
onk
PRO
0
550
反実仮想機械学習とは何か
usaito
PRO
7
2.4k
**強い**エンジニアのなり方 - フィードバックサイクルを勝ち取る / grow one day each day
soudai
62
18k
0→1開発における技術選定において一番大切なこと
bicstone
1
330
テストプロセスで大事にしていること #jasstnano
makky_tyuyan
0
130
オーナーシップを持つ領域を明確にする
konifar
12
2.7k
入社後初めてのタスクでk8sアップグレードした話.pdf
kkato1
1
380
HEXA OSINT CTF V3 作戦会議
meow_noisy
0
110
Featured
See All Featured
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
29
46k
Building Better People: How to give real-time feedback that sticks.
wjessup
354
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
273
13k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.4k
Code Reviewing Like a Champion
maltzj
513
39k
Building Applications with DynamoDB
mza
88
5.6k
GraphQLとの向き合い方2022年版
quramy
31
12k
What's new in Ruby 2.0
geeforr
337
31k
Making Projects Easy
brettharned
108
5.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.3k
Testing 201, or: Great Expectations
jmmastey
27
6.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/