summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e772b37)
This simplifies the code a bit and reduces the translation
overhead for looking directly at data from tools shipped
with Xapian.
While we're at it, fix thread-all.t :)
);
my %bool_pfx_external = (
);
my %bool_pfx_external = (
- # do we still need these? probably not..
- path => 'XPATH',
mid => 'Q', # uniQue id (Message-ID)
);
mid => 'Q', # uniQue id (Message-ID)
);
# da (diff a/ removed lines)
# db (diff b/ added lines)
# da (diff a/ removed lines)
# db (diff b/ added lines)
-my %all_pfx = (%bool_pfx_internal, %bool_pfx_external, %prob_prefix);
-
-sub xpfx { $all_pfx{$_[0]} }
-
-my $mail_query = Search::Xapian::Query->new(xpfx('type') . 'mail');
+my $mail_query = Search::Xapian::Query->new('T' . 'mail');
sub xdir {
my (undef, $git_dir) = @_;
sub xdir {
my (undef, $git_dir) = @_;
my $smsg = eval { $self->lookup_message($mid) };
return { total => 0, msgs => [] } unless $smsg;
my $smsg = eval { $self->lookup_message($mid) };
return { total => 0, msgs => [] } unless $smsg;
- my $qtid = Search::Xapian::Query->new(xpfx('thread').$smsg->thread_id);
+ my $qtid = Search::Xapian::Query->new('G' . $smsg->thread_id);
my $path = $smsg->path;
if (defined $path && $path ne '') {
my $path = id_compress($smsg->path);
my $path = $smsg->path;
if (defined $path && $path ne '') {
my $path = id_compress($smsg->path);
- my $qsub = Search::Xapian::Query->new(xpfx('path').$path);
+ my $qsub = Search::Xapian::Query->new('XPATH' . $path);
$qtid = Search::Xapian::Query->new(OP_OR, $qtid, $qsub);
}
$opts ||= {};
$qtid = Search::Xapian::Query->new(OP_OR, $qtid, $qsub);
}
$opts ||= {};
my ($self, $mid) = @_;
$mid = mid_clean($mid);
my ($self, $mid) = @_;
$mid = mid_clean($mid);
- my $doc_id = $self->find_unique_doc_id('mid', $mid);
+ my $doc_id = $self->find_unique_doc_id('Q' . $mid);
my $smsg;
if (defined $doc_id) {
# raises on error:
my $smsg;
if (defined $doc_id) {
# raises on error:
}
sub find_unique_doc_id {
}
sub find_unique_doc_id {
- my ($self, $term, $value) = @_;
+ my ($self, $termval) = @_;
- my ($begin, $end) = $self->find_doc_ids($term, $value);
+ my ($begin, $end) = $self->find_doc_ids($termval);
return undef if $begin->equal($end); # not found
return undef if $begin->equal($end); # not found
# sanity check
$begin->inc;
# sanity check
$begin->inc;
- $begin->equal($end) or die "Term '$term:$value' is not unique\n";
+ $begin->equal($end) or die "Term '$termval' is not unique\n";
$rv;
}
# returns begin and end PostingIterator
sub find_doc_ids {
$rv;
}
# returns begin and end PostingIterator
sub find_doc_ids {
- my ($self, $term, $value) = @_;
-
- $self->find_doc_ids_for_term(xpfx($term) . $value);
-}
-
-# returns begin and end PostingIterator
-sub find_doc_ids_for_term {
- my ($self, $term) = @_;
+ my ($self, $termval) = @_;
- ($db->postlist_begin($term), $db->postlist_end($term));
+ ($db->postlist_begin($termval), $db->postlist_end($termval));
}
# normalize subjects so they are suitable as pathnames for URLs
}
# normalize subjects so they are suitable as pathnames for URLs
use Carp qw(croak);
use POSIX qw(strftime);
require PublicInbox::Git;
use Carp qw(croak);
use POSIX qw(strftime);
require PublicInbox::Git;
-*xpfx = *PublicInbox::Search::xpfx;
use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
use constant {
use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
use constant {
}
$smsg = PublicInbox::SearchMsg->new($mime);
my $doc = $smsg->{doc};
}
$smsg = PublicInbox::SearchMsg->new($mime);
my $doc = $smsg->{doc};
- $doc->add_term(xpfx('mid') . $mid);
+ $doc->add_term('Q' . $mid);
my $subj = $smsg->subject;
if ($subj ne '') {
my $path = $self->subject_path($subj);
my $subj = $smsg->subject;
if ($subj ne '') {
my $path = $self->subject_path($subj);
- $doc->add_term(xpfx('path') . id_compress($path));
+ $doc->add_term('XPATH' . id_compress($path));
}
add_values($smsg, $bytes, $num);
}
add_values($smsg, $bytes, $num);
} else {
$tid = defined $old_tid ? $old_tid : $self->next_thread_id;
}
} else {
$tid = defined $old_tid ? $old_tid : $self->next_thread_id;
}
- $doc->add_term(xpfx('thread') . $tid);
+ $doc->add_term('G' . $tid);
my $tid = $self->next_thread_id;
my $doc = Search::Xapian::Document->new;
my $tid = $self->next_thread_id;
my $doc = Search::Xapian::Document->new;
- $doc->add_term(xpfx('mid') . $mid);
- $doc->add_term(xpfx('thread') . $tid);
- $doc->add_term(xpfx('type') . 'ghost');
+ $doc->add_term('Q' . $mid);
+ $doc->add_term('G' . $tid);
+ $doc->add_term('T' . 'ghost');
my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid);
$self->{xdb}->add_document($doc);
my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid);
$self->{xdb}->add_document($doc);
sub merge_threads {
my ($self, $winner_tid, $loser_tid) = @_;
return if $winner_tid == $loser_tid;
sub merge_threads {
my ($self, $winner_tid, $loser_tid) = @_;
return if $winner_tid == $loser_tid;
- my ($head, $tail) = $self->find_doc_ids('thread', $loser_tid);
- my $thread_pfx = xpfx('thread');
+ my ($head, $tail) = $self->find_doc_ids('G' . $loser_tid);
my $db = $self->{xdb};
for (; $head != $tail; $head->inc) {
my $docid = $head->get_docid;
my $doc = $db->get_document($docid);
my $db = $self->{xdb};
for (; $head != $tail; $head->inc) {
my $docid = $head->get_docid;
my $doc = $db->get_document($docid);
- $doc->remove_term($thread_pfx . $loser_tid);
- $doc->add_term($thread_pfx . $winner_tid);
+ $doc->remove_term('G' . $loser_tid);
+ $doc->add_term('G' . $winner_tid);
$db->replace_document($docid, $doc);
}
}
$db->replace_document($docid, $doc);
}
}
sub new {
my ($class, $mime) = @_;
my $doc = Search::Xapian::Document->new;
sub new {
my ($class, $mime) = @_;
my $doc = Search::Xapian::Document->new;
- $doc->add_term(PublicInbox::Search::xpfx('type') . 'mail');
+ $doc->add_term('T' . 'mail');
bless { type => 'mail', doc => $doc, mime => $mime }, $class;
}
bless { type => 'mail', doc => $doc, mime => $mime }, $class;
}
is($found->mid, 'root@s', 'mid set correctly');
ok(int($found->thread_id) > 0, 'thread_id is an integer');
is($found->mid, 'root@s', 'mid set correctly');
ok(int($found->thread_id) > 0, 'thread_id is an integer');
my @exp = sort qw(root@s last@s);
my @exp = sort qw(root@s last@s);
- my $res = $ro->query("path:hello_world");
- my @res = filter_mids($res);
- is_deeply(\@res, \@exp, 'got expected results for path: match');
-
- foreach my $p (qw(hello hello_ hello_world2 hello_world_)) {
- $res = $ro->query("path:$p");
- is($res->{total}, 0, "path variant `$p' does not match");
- }
$res = $ro->query('s:(Hello world)');
@res = filter_mids($res);
$res = $ro->query('s:(Hello world)');
@res = filter_mids($res);