diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index c6275ffa1..7d0634ca1 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -28,6 +28,17 @@ returns # enable search only for agents and admins return [] if !current_user.is_role('Agent') && !current_user.is_role('Admin') + # try search index backend + if Setting.get('es_url') + ids = SearchIndexBackend.search( query, limit, 'Organization' ) + organizations = [] + ids.each { |id| + organizations.push Organization.lookup( :id => id ) + } + return organizations + end + + # fallback do sql query # do query organizations = Organization.find( :all, diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb index 810a23ab7..f9318f613 100644 --- a/app/models/ticket/search.rb +++ b/app/models/ticket/search.rb @@ -40,6 +40,17 @@ returns end end + # try search index backend + if Setting.get('es_url') + ids = SearchIndexBackend.search( query, limit, 'Ticket' ) + tickets = [] + ids.each { |id| + tickets.push Ticket.lookup( :id => id ) + } + return tickets + end + + # fallback do sql query # do query tickets_all = Ticket.select('DISTINCT(tickets.id)'). where(conditions). diff --git a/app/models/user/search.rb b/app/models/user/search.rb index 705b0cee5..8948d3cd6 100644 --- a/app/models/user/search.rb +++ b/app/models/user/search.rb @@ -44,6 +44,17 @@ returns # enable search only for agents and admins return [] if !current_user.is_role('Agent') && !current_user.is_role('Admin') + # try search index backend + if Setting.get('es_url') + ids = SearchIndexBackend.search( query, limit, 'User' ) + users = [] + ids.each { |id| + users.push User.lookup( :id => id ) + } + return users + end + + # fallback do sql query # do query users = User.find( :all,