diff options
author | Arne Georg Gleditsch <argggh@lxr.linpro.no> | 2010-08-06 20:48:40 +0200 |
---|---|---|
committer | Arne Georg Gleditsch <argggh@lxr.linpro.no> | 2010-08-06 20:48:40 +0200 |
commit | 1646fcb8b0e9fd85a8f94e26f1de2d1fbf9647ab (patch) | |
tree | e48fc6d9ce5d7bf8e231987342eddf008434e161 /lib/LXRng/Search/Xapian.pm | |
parent | 1c4967095e1e3f4e3ea7b36e540da0fca7fec403 (diff) |
Make underscore matching a bit more clever.
Diffstat (limited to 'lib/LXRng/Search/Xapian.pm')
-rw-r--r-- | lib/LXRng/Search/Xapian.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/LXRng/Search/Xapian.pm b/lib/LXRng/Search/Xapian.pm index f337962..804ae14 100644 --- a/lib/LXRng/Search/Xapian.pm +++ b/lib/LXRng/Search/Xapian.pm @@ -145,6 +145,12 @@ sub flush { $self->wrdb->flush(); } +sub remove_underscores { + my ($s) = @_; + $s =~ s/_/ /g; + return $s; +} + sub search { my ($self, $rel_id, $query) = @_; @@ -158,11 +164,12 @@ sub search { $query =~ s/\b([A-Z]+)\b/\L$1\E/g; } else { - $query =~ s/([\S_]+_[\S_]*)/\"$1\"/g; - $query =~ s/_/ /g; + $query =~ s/([\S_]+_[\S_]*)/"(\"$1\" || \"".remove_underscores($1)."\")"/ge; $query =~ s/\b(?![A-Z][^A-Z]*\b)(\S+)/\L$1\E/g; } $query =~ s/\b(\w+)\b/indexed_term($1) ? $1 : ""/ge; + $query =~ s/\|\|/ OR /g; + $query =~ s/\&\&/ AND /g; my $query = $qp->parse_query($query); $query = Search::Xapian::Query |