Subject: Re: [sup-devel] [PATCH] fix searching for non-lowercase labels

From: Rich Lane <[email-masked]>
Date: Fri, 08 Oct 2010 00:21:41 -0400

Applied to master.
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Sascha Silbe <[email-masked]>
Date: Wed, 29 Sep 2010 16:16:15 +0200

Case is preserved when marshalling labels (stored as document data), but label
terms are stored lowercase. build_xapian_query uses mkterm and thus already
converts labels to lowercase when searching. parse_query accepts a Xapian
query string from the user and needs to explicitly convert labels to
lowercase, which it now does.

Signed-off-by: Sascha Silbe <[email-masked]>
---
 lib/sup/index.rb |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index a72bec6..f90d0d9 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -346,6 +346,12 @@ EOS
       end
     end
 
+    ## labels are stored lower-case in the index
+    subs = subs.gsub(/\blabel:(\S+)\b/) do
+      label = $1
+      "label:#{label.downcase}"
+    end
+
     ## if we see a label:deleted or a label:spam term anywhere in the query
     ## string, we set the extra load_spam or load_deleted options to true.
     ## bizarre? well, because the query allows arbitrary parenthesized boolean
-- 
1.7.1