forked from elastic/elasticsearch-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_controller.rb
41 lines (38 loc) · 1000 Bytes
/
search_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class SearchController < ApplicationController
def index
tags = { pre_tags: '<em class="hl">', post_tags: '</em>' }
@artists = Artist.search \
query: {
multi_match: {
query: params[:q],
fields: ['name^10','members^2','profile']
}
},
highlight: {
tags_schema: 'styled',
fields: {
name: { number_of_fragments: 0 },
members_combined: { number_of_fragments: 0 },
profile: { fragment_size: 50 }
}
}
@albums = Album.search \
query: {
multi_match: {
query: params[:q],
fields: ['title^100','tracklist.title^10','notes^1']
}
},
highlight: {
tags_schema: 'styled',
fields: {
title: { number_of_fragments: 0 },
'tracklist.title' => { number_of_fragments: 0 },
notes: { fragment_size: 50 }
}
}
end
def suggest
render json: Suggester.new(params)
end
end