Class: Workarea::Search::SearchSuggestions
- Inherits:
-
Object
- Object
- Workarea::Search::SearchSuggestions
show all
- Includes:
- Query
- Defined in:
- app/queries/workarea/search/search_suggestions.rb
Instance Method Summary
collapse
Methods included from Query
#additional_options, #aggregations, #body, #id, #initialize, #load_model_from, #loaded_results, #post_filter, #query_string, #response, #scroll, #stats, #total
Instance Method Details
#query ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/queries/workarea/search/search_suggestions.rb', line 16
def query
{
bool: {
must: [
{
match_phrase_prefix: {
'content.name': {
query: sanitized_string,
max_expansions: 10
}
}
},
{ term: { 'active.now' => true } }
]
}
}
end
|
#results ⇒ Object
8
9
10
|
# File 'app/queries/workarea/search/search_suggestions.rb', line 8
def results
response['hits']['hits']
end
|
#sanitized_string ⇒ Object
12
13
14
|
# File 'app/queries/workarea/search/search_suggestions.rb', line 12
def sanitized_string
@sanitized_query ||= QueryString.new(params[:q]).sanitized
end
|
#size ⇒ Object
38
39
40
|
# File 'app/queries/workarea/search/search_suggestions.rb', line 38
def size
Workarea.config.search_suggestions
end
|
#sort ⇒ Object
34
35
36
|
# File 'app/queries/workarea/search/search_suggestions.rb', line 34
def sort
{ type: :desc }
end
|