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
73
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
210
Tirando Proveito das Rails Engines
nandosousafr
0
93
5 basic tips for RubyOnRails projects
nandosousafr
1
400
Workshop Git para o DevInSanta meetup.
nandosousafr
0
72
Other Decks in Technology
See All in Technology
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
12k
RubyOnRailsOnDevin+α / DevinMeetupJapan#2
ginkouno
0
360
菸酒生在 LINE Taiwan 的後端雙刀流
line_developers_tw
PRO
0
140
データ戦略部門 紹介資料
sansan33
PRO
1
3.2k
工具人的一生: 開發很多 AI 工具讓我 慵懶過一生
line_developers_tw
PRO
0
140
上長や社内ステークホルダーに対する解像度を上げて、より良い補完関係を築く方法 / How-to-increase-resolution-and-build-better-complementary-relationships-with-your-bosses-and-internal-stakeholders
madoxten
13
7.6k
堅牢な認証基盤の実現 TypeScriptで代数的データ型を活用する
kakehashi
PRO
2
220
Javalinの紹介
notoh
0
100
「実体」で築く共通認識: 開発現場のコミュニケーション最適化 / Let's Get on the Same Page with Concrete Artifacts: Optimization of Communication in dev teams
kazizi55
0
140
Securing your Lambda 101
chillzprezi
0
270
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.6k
評価の納得感を2段階高める「構造化フィードバック」
aloerina
1
160
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.4k
Speed Design
sergeychernyshev
30
990
Thoughts on Productivity
jonyablonski
69
4.7k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
KATA
mclloyd
29
14k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
6
690
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Docker and Python
trallard
44
3.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
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/