aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index 2279c2e66..3a95ab50b 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -4,10 +4,9 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: acts_as_xapian.rb,v 1.7 2008-04-24 09:57:48 francis Exp $
+# $Id: acts_as_xapian.rb,v 1.8 2008-04-24 10:26:50 francis Exp $
# TODO:
-# Spell checking
# Eager loading
# Function to keep a model out of the index entirely
@@ -50,6 +49,8 @@
# * Date range searching - maybe this works in acts_as_solr, but I never found
# out how.
#
+# * Spelling correction - "did you mean?" built in and just works.
+#
# * Multiple models - acts_as_xapian searches multiple models if you like,
# returning them mixed up together by relevancy. This is like multi_solr_search,
# only it is the default mode of operation and is properly supported.
@@ -124,6 +125,7 @@
# Returns an ActsAsXapian::Search object. Useful methods are:
# description - a techy one, to check how the query has been parsed
# matches_estimated - a guesstimate at the total number of hits
+# spelling_correction - the corrected query string if there is a correction, otherwise nil
# results - an array of hashes containing:
# :model - your Rails model, this is what you most want!
# :weight - relevancy measure
@@ -286,6 +288,15 @@ module ActsAsXapian
self.matches.matches_estimated
end
+ # Return query string with spelling correction
+ def spelling_correction
+ correction = ActsAsXapian.query_parser.get_corrected_query_string
+ if correction.empty?
+ return nil
+ end
+ return correction
+ end
+
# Return array of models found
def results
# Pull out all the results