diff --git a/plugins/elasticsearch/helpers/elasticsearch_helper.rb b/plugins/elasticsearch/helpers/elasticsearch_helper.rb index 3b65121..8fbe049 100644 --- a/plugins/elasticsearch/helpers/elasticsearch_helper.rb +++ b/plugins/elasticsearch/helpers/elasticsearch_helper.rb @@ -64,39 +64,47 @@ module ElasticsearchHelper private - def get_query text, klass=nil - fields = klass.nil? ? (fields_from_models searchable_models) : (fields_from_models [klass]) - query = {} - unless text.blank? - text = text.downcase - query = { - query: { - multi_match: { - query: text, - type: "phrase", - fields: fields, - zero_terms_query: "none" - }, - }, - sort: [ - {"name.raw" => {"order" => "asc"}} - ], - suggest: { - autocomplete: { - text: text, - term: { - field: "name", - suggest_mode: "always" - } - } + def searchable_models + SEARCHABLE_TYPES.except(:all).keys.map { | model | model.to_s.classify.constantize } + end + + def query_method expression, fields + query_exp = {} + if expression.blank? + query_exp = { + match_all: {} + } + else + query_exp = { + multi_match: { + query: expression, + type: "phrase", + fields: fields, + zero_terms_query: "none" } } end - query + query_exp end - def searchable_models - SEARCHABLE_TYPES.except(:all).keys.map { | model | model.to_s.classify.constantize } + def get_query text="", klass=nil + fields = klass.nil? ? (fields_from_models searchable_models) : (fields_from_models [klass]) + query = { + query: query_method(text, fields), + sort: [ + {"name.raw" => {"order" => "asc"}} + ], + suggest: { + autocomplete: { + text: text, + term: { + field: "name", + suggest_mode: "always" + } + } + } + } + query end end diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/_person_display.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/_person_display.html.erb index 42d48e0..08ac688 100644 --- a/plugins/elasticsearch/views/elasticsearch_plugin/_person_display.html.erb +++ b/plugins/elasticsearch/views/elasticsearch_plugin/_person_display.html.erb @@ -3,7 +3,7 @@ <%= profile_image person %>
<%= person.description %>
-- libgit2 0.21.2