diff options
author | Eric Wong <e@80x24.org> | 2015-09-05 08:56:54 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-09-05 08:58:51 +0000 |
commit | daeb042141ce15a6f8b46da9d600ab4b417c93a1 (patch) | |
tree | 777ffb70f9b3af271972529533119f37da6aa030 /lib/PublicInbox/Search.pm | |
parent | 79601e109dc8162b4c62f7c63cfc6518b0f00112 (diff) | |
download | public-inbox-daeb042141ce15a6f8b46da9d600ab4b417c93a1.tar.gz |
In case a URL gets truncated (as is common with long URLs), we can rely on Xapian for partial matches and bring the user to their destination.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r-- | lib/PublicInbox/Search.pm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 20650554..e7ea96c7 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -269,4 +269,13 @@ sub enquire { $self->{enquire} ||= Search::Xapian::Enquire->new($self->{xdb}); } +sub mid_prefix { + my ($self, $mpfx) = @_; + my $query = eval { $self->qp->parse_query("m:$mpfx", FLAG_PARTIAL) }; + return if $@; + my $res = $self->do_enquire($query, { relevance => 1 }); + return unless $res->{total}; + [ map { $_->mid } @{$res->{msgs}} ]; +} + 1; |