]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Isearch.pm
No ext_urls
[public-inbox.git] / lib / PublicInbox / Isearch.pm
index e362c80aec14ca3c60572c716f2954089406ca8e..2b45e08e8447b67d8234852f0f7290f84c907b26 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Provides everything the PublicInbox::Search object does;
@@ -25,6 +25,7 @@ SELECT ibx_id FROM inboxes WHERE eidx_key = ? LIMIT 1
                die "E: `$self->{eidx_key}' not in $self->{es}->{topdir}\n";
 }
 
+sub query_approxidate { $_[0]->{es}->query_approxidate($_[1], $_[2]) }
 
 sub mset {
        my ($self, $str, $opt) = @_;
@@ -33,7 +34,7 @@ sub mset {
        if (my $uid_range = $opt{uid_range}) {
                my ($beg, $end) = @$uid_range;
                my $ibx_id = $self->{-ibx_id} //= _ibx_id($self);
-               my $dbh = $self->{es}->{over}->dbh;
+               my $dbh = $self->{es}->over->dbh;
                my $sth = $dbh->prepare_cached(<<'', undef, 1);
 SELECT MIN(docid) FROM xref3 WHERE ibx_id = ? AND xnum >= ? AND xnum <= ?
 
@@ -61,19 +62,18 @@ sub mset_to_artnums {
        my $docids = PublicInbox::Search::mset_to_artnums($self->{es}, $mset);
        my $ibx_id = $self->{-ibx_id} //= _ibx_id($self);
        my $qmarks = join(',', map { '?' } @$docids);
-       if ($opt && ($opt->{mset} // 0) == 2) { # opt->{mset} = 2 was used
+       if ($opt && ($opt->{relevance} // 0) == -1) { # -1 => ENQ_ASCENDING
                my $range = '';
                my @r;
                if (my $r = $opt->{uid_range}) {
                        $range = 'AND xnum >= ? AND xnum <= ?';
                        @r = @$r;
                }
-               my $rows = $self->{es}->over->dbh->
-                       selectall_arrayref(<<"", undef, $ibx_id, @$docids, @r);
+               return $self->{es}->over->dbh->
+                       selectcol_arrayref(<<"", undef, $ibx_id, @$docids, @r);
 SELECT xnum FROM xref3 WHERE ibx_id = ? AND docid IN ($qmarks) $range
 ORDER BY xnum ASC
 
-               return [ map { $_->[0] } @$rows ];
        }
 
        my $rows = $self->{es}->over->dbh->