Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

suusan2go
Copy link
Collaborator

先に #153 をマージしてください

@suusan2go suusan2go force-pushed the elasticsearch branch 3 times, most recently from 2cd1dc1 to 539b9a3 Compare February 14, 2016 11:37
@suusan2go
Copy link
Collaborator Author

特に必要性は感じてないけど、勉強のために作ったやで
image
image


included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本当は非同期callbackの方がいいと思うけど、面倒だしとりあえずコレで。

@suusan2go
Copy link
Collaborator Author

こちらのブログを参考にしました。
http://ruby-rails.hatenadiary.com/entry/20151018/1445142266

@suusan2go suusan2go changed the title [WIP]Elasticsearchでポエムを全文検索 Elasticsearchでポエムを全文検索 Feb 14, 2016
describe '.search' do
let!(:nasu_poem) { create(:poem, title: '那須', description: 'がんばれよ!') }
let!(:suzuki_poem) { create(:poem, title: '鈴木さん', description: 'やったぜ!') }
let!(:iwaki_poem) { create(:poem, title: '岩木山', description: 'がんばれよ!那須さん') }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

笑ったw

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

山かwwww

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ス、スミマセン・・・直さないけど

@nasum
Copy link
Collaborator

nasum commented Feb 14, 2016

多分大丈夫だと思うけどよくわかってないこと多いからちゃんと読んでからマージするね。

@suusan2go
Copy link
Collaborator Author

ちゃんと読んでほしい(自分もそんなに理解できているわけではない)


def index
@poems = Poem.all.order(id: :desc).includes(:user).page(params[:page])
@poems = Poem.search(@search_params).page(params[:page]).records

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

できれば /api/poems の方も対応してほしいな・・・

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants