Added init version of ES search.

This commit is contained in:
Martin Edenhofer 2014-01-30 00:55:25 +01:00
parent 677f5c0e6e
commit b163b2eb0f
3 changed files with 33 additions and 0 deletions

View file

@ -28,6 +28,17 @@ returns
# enable search only for agents and admins # enable search only for agents and admins
return [] if !current_user.is_role('Agent') && !current_user.is_role('Admin') 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 # do query
organizations = Organization.find( organizations = Organization.find(
:all, :all,

View file

@ -40,6 +40,17 @@ returns
end end
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 # do query
tickets_all = Ticket.select('DISTINCT(tickets.id)'). tickets_all = Ticket.select('DISTINCT(tickets.id)').
where(conditions). where(conditions).

View file

@ -44,6 +44,17 @@ returns
# enable search only for agents and admins # enable search only for agents and admins
return [] if !current_user.is_role('Agent') && !current_user.is_role('Admin') 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 # do query
users = User.find( users = User.find(
:all, :all,