about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-05 08:00:12 +0000
committerEric Wong <e@80x24.org>2015-09-05 08:11:45 +0000
commit79601e109dc8162b4c62f7c63cfc6518b0f00112 (patch)
tree51d2e8d2ecaf4b56327c56bba5527ddf5ec97507 /lib
parentcc5ca11dbe88aab95cc593aa94f5d8a6ad5a2eb4 (diff)
downloadpublic-inbox-79601e109dc8162b4c62f7c63cfc6518b0f00112.tar.gz
We should not need to use QueryParser for internal queries,
but rather for external ones.

We'll also be exposing searching Message-IDs with the "mid:" prefix
for broken mids on some servers, and enabling partial searching
with 'm' to help with URL truncations.

Since thread IDs may be volatile, they cannot be exposed to the
public, there's no reason to expose them to the query parser,
either.

Also, add 's:' as an alternative probabilistic prefix to 'subject'
as it is shorter.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Search.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index b6e71da0..20650554 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -37,16 +37,18 @@ use constant {
 # setup prefixes
 my %bool_pfx_internal = (
         type => 'T', # "mail" or "ghost"
-        mid => 'Q', # uniQue id (Message-ID)
+        thread => 'G', # newsGroup (or similar entity - e.g. a web forum name)
 );
 
 my %bool_pfx_external = (
         path => 'XPATH',
-        thread => 'G', # newsGroup (or similar entity - e.g. a web forum name)
+        mid => 'Q', # uniQue id (Message-ID)
 );
 
 my %prob_prefix = (
         subject => 'S',
+        s => 'S', # for mairix compatibility
+        m => 'Q', # 'mid' is exact, 'm' can do partial
 );
 
 my %all_pfx = (%bool_pfx_internal, %bool_pfx_external, %prob_prefix);
@@ -91,8 +93,8 @@ sub query {
 
 sub get_subject_path {
         my ($self, $path, $opts) = @_;
-        my $query = $self->qp->parse_query("path:".mid_compress($path), 0);
-        $self->do_enquire($query, $opts);
+        my $q = Search::Xapian::Query->new(xpfx("path").mid_compress($path));
+        $self->do_enquire($q, $opts);
 }
 
 sub get_thread {
@@ -100,9 +102,9 @@ sub get_thread {
         my $smsg = eval { $self->lookup_message($mid) };
 
         return { total => 0, msgs => [] } unless $smsg;
-        my $qp = $self->qp;
-        my $qtid = $qp->parse_query('thread:'.$smsg->thread_id, 0);
-        my $qsub = $qp->parse_query('path:'.mid_compress($smsg->path), 0);
+        my $qtid = Search::Xapian::Query->new(xpfx('thread').$smsg->thread_id);
+        my $path = mid_compress($smsg->path);
+        my $qsub = Search::Xapian::Query->new(xpfx('path').$path);
         my $query = Search::Xapian::Query->new(OP_OR, $qtid, $qsub);
         $self->do_enquire($query, $opts);
 }