-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elasticsearchでポエムを全文検索 #154
base: master
Are you sure you want to change the base?
Conversation
2cd1dc1
to
539b9a3
Compare
539b9a3
to
a76b0db
Compare
|
||
included do | ||
include Elasticsearch::Model | ||
include Elasticsearch::Model::Callbacks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本当は非同期callbackの方がいいと思うけど、面倒だしとりあえずコレで。
こちらのブログを参考にしました。 |
describe '.search' do | ||
let!(:nasu_poem) { create(:poem, title: '那須', description: 'がんばれよ!') } | ||
let!(:suzuki_poem) { create(:poem, title: '鈴木さん', description: 'やったぜ!') } | ||
let!(:iwaki_poem) { create(:poem, title: '岩木山', description: 'がんばれよ!那須さん') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
笑ったw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
山かwwww
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ス、スミマセン・・・直さないけど
多分大丈夫だと思うけどよくわかってないこと多いからちゃんと読んでからマージするね。 |
ちゃんと読んでほしい(自分もそんなに理解できているわけではない) |
|
||
def index | ||
@poems = Poem.all.order(id: :desc).includes(:user).page(params[:page]) | ||
@poems = Poem.search(@search_params).page(params[:page]).records |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
できれば /api/poems
の方も対応してほしいな・・・
先に #153 をマージしてください