From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E4AF1200F6 for ; Sat, 5 Sep 2015 09:01:11 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/6] search: tweak parsing for internal queries Date: Sat, 5 Sep 2015 09:01:07 +0000 Message-Id: <1441443668-21092-6-git-send-email-e@80x24.org> In-Reply-To: <1441443668-21092-1-git-send-email-e@80x24.org> References: <1441443668-21092-1-git-send-email-e@80x24.org> List-Id: 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. --- lib/PublicInbox/Search.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index b6e71da..2065055 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); } -- EW