Class: WorksSearch

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/searches/works_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#queryObject

Returns the value of attribute query


4
5
6
# File 'app/searches/works_search.rb', line 4

def query
  @query
end

Instance Method Details

#allObject


17
18
19
# File 'app/searches/works_search.rb', line 17

def all
	index.filter{ match_all }
end

#indexObject


5
6
7
# File 'app/searches/works_search.rb', line 5

def index
	WorksIndex
end

#query_stringObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/searches/works_search.rb', line 21

def query_string
	index.query(bool: {
			should: [
				{
					multi_match: {
						fields: [:original_title],# :author, :description],
						query: query,
						operator: "AND"
					}
				},
				{
					multi_match: {
						fields: [:original_title],#, :author, :description],
						query: query,
						fuzziness: "AUTO",
						operator: "AND"
					}
				}
			]
		}
	) if query.present?
end

#searchObject


9
10
11
# File 'app/searches/works_search.rb', line 9

def search
	query_string
end

#works_countObject


13
14
15
# File 'app/searches/works_search.rb', line 13

def works_count
	index.filter({ type: { value: "work"}}).search_type(:count)
end