From c62db4918a9a4497fc85628bd07110e55ad8fac5 Mon Sep 17 00:00:00 2001 From: francis Date: Mon, 14 Apr 2008 14:46:47 +0000 Subject: Centralise call to multi_solr_search --- app/models/info_request.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index cf4d6c206..775138b84 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.84 2008-04-14 10:05:21 francis Exp $ +# $Id: info_request.rb,v 1.85 2008-04-14 14:46:48 francis Exp $ require 'digest/sha1' @@ -111,6 +111,22 @@ class InfoRequest < ActiveRecord::Base true end + # Central function to do all searches + def InfoRequest.full_search(query, order, per_page, page, html_highlight) + offset = (page - 1) * per_page + return InfoRequestEvent.multi_solr_search(query, :models => [ PublicBody, User ], + :limit => per_page, :offset => offset, + :highlight => { + :prefix => html_highlight ? '' : "*", + :suffix => html_highlight ? '' : "*", + :fragsize => 250, + :fields => ["solr_text_main", "title", # InfoRequestEvent + "name", "short_name", # PublicBody + "name" # User + ]}, :order => order + ) + end + public # When name is changed, also change the url name def title=(title) -- cgit v1.2.3