]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Search.pm
update copyright headers and email addresses
[public-inbox.git] / lib / PublicInbox / Search.pm
index 20650554c3337e45cec5c4030aad83de524cfacb..2b33b395e6340544fc0fa1ff142e9587f89235e1 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015, all contributors <meta@public-inbox.org>
+# Copyright (C) 2015 all contributors <meta@public-inbox.org>
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
 # based on notmuch, but with no concept of folders, files or flags
 package PublicInbox::Search;
@@ -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;