diff options
author | David Cabo <david@calibea.com> | 2011-08-22 22:51:54 +0200 |
---|---|---|
committer | David Cabo <david@calibea.com> | 2011-08-22 22:51:54 +0200 |
commit | 349163c4de2d0cfe52c12ef41dae62f8555cf9c3 (patch) | |
tree | eab8ec871290e9db117890ac4729e0484249644f /app/controllers/public_body_controller.rb | |
parent | 88b9e2c08526983fcf5985fdd2fcdf420f45f51c (diff) | |
parent | 6c692dea355ea2a057a01e795466a19f81b494aa (diff) |
Merge branch 'asktheeu' into asktheeu-new-design
Diffstat (limited to 'app/controllers/public_body_controller.rb')
-rw-r--r-- | app/controllers/public_body_controller.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 05acf4868..ea1ffb619 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -168,5 +168,17 @@ class PublicBodyController < ApplicationController :filename => 'all-authorities.csv', :disposition =>'attachment', :encoding => 'utf8') end + + # Type ahead search + def search_typeahead + # Since acts_as_xapian doesn't support the Partial match flag, we work around it + # by making the last work a wildcard, which is quite the same + query = params[:q] + '*' + + query = query.split(' ').join(' OR ') # XXX: HACK for OR instead of default AND! + @xapian_requests = perform_search([PublicBody], query, 'relevant', 'request_collapse', 5) + + render :partial => "public_body/search_ahead" + end end |