about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index bc820b64..01bbe73d 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -311,6 +311,12 @@ sub _do_enquire {
         retry_reopen($self, \&_enquire_once, [ $self, $query, $opts ]);
 }
 
+# returns true if all docs have the THREADID value
+sub has_threadid ($) {
+        my ($self) = @_;
+        (xdb($self)->get_metadata('has_threadid') // '') eq '1';
+}
+
 sub _enquire_once { # retry_reopen callback
         my ($self, $query, $opts) = @{$_[0]};
         my $xdb = xdb($self);
@@ -328,7 +334,9 @@ sub _enquire_once { # retry_reopen callback
         }
 
         # `mairix -t / --threads' or JMAP collapseThreads
-        $enquire->set_collapse_key(THREADID) if $opts->{thread};
+        if ($opts->{thread} && has_threadid($self)) {
+                $enquire->set_collapse_key(THREADID);
+        }
 
         my $offset = $opts->{offset} || 0;
         my $limit = $opts->{limit} || 50;