user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
* [PATCH 0/2] internal search parameter naming
@ 2020-12-27 19:38 Eric Wong
  2020-12-27 19:38 ` [PATCH 1/2] search: remove pointless {relevance} setting Eric Wong
  2020-12-27 19:38 ` [PATCH 2/2] search: remove {mset} option for ->mset method Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2020-12-27 19:38 UTC (permalink / raw)
  To: meta

Bad naming confuses me :x

Eric Wong (2):
  search: remove pointless {relevance} setting
  search: remove {mset} option for ->mset method

 lib/PublicInbox/ExtMsg.pm  |  2 +-
 lib/PublicInbox/IMAP.pm    |  2 +-
 lib/PublicInbox/Isearch.pm |  2 +-
 lib/PublicInbox/Mbox.pm    |  2 +-
 lib/PublicInbox/Search.pm  | 25 +++++++++++++------------
 5 files changed, 17 insertions(+), 16 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] search: remove pointless {relevance} setting
  2020-12-27 19:38 [PATCH 0/2] internal search parameter naming Eric Wong
@ 2020-12-27 19:38 ` Eric Wong
  2020-12-27 19:38 ` [PATCH 2/2] search: remove {mset} option for ->mset method Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-12-27 19:38 UTC (permalink / raw)
  To: meta

SearchView will set it to `undef', others will set the 'mset'
option (for the ->mset method :P) to 2 which causes {relevance}
to be ignored.

And the 'mset' option is poorly named now that the message
is named ->mset...
---
 lib/PublicInbox/Search.pm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 05c679c9..ffd19a1f 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -287,7 +287,6 @@ sub mset {
 	$opts ||= {};
 	my $qp = $self->{qp} //= qparse_new($self);
 	my $query = $qp->parse_query($query_string, $self->{qp_flags});
-	$opts->{relevance} = 1 unless exists $opts->{relevance};
 	_do_enquire($self, $query, $opts);
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] search: remove {mset} option for ->mset method
  2020-12-27 19:38 [PATCH 0/2] internal search parameter naming Eric Wong
  2020-12-27 19:38 ` [PATCH 1/2] search: remove pointless {relevance} setting Eric Wong
@ 2020-12-27 19:38 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-12-27 19:38 UTC (permalink / raw)
  To: meta

The ->mset method always returns a Xapian mset nowadays, so
naming a parameter {mset} is too confusing.  As it does with
MiscSearch, setting the {relevance} parameter to -1 now sorts by
ascending docid order.  -2 is now supported for descending
docid order, too, since it may be useful for lei users.
---
 lib/PublicInbox/ExtMsg.pm  |  2 +-
 lib/PublicInbox/IMAP.pm    |  2 +-
 lib/PublicInbox/Isearch.pm |  2 +-
 lib/PublicInbox/Mbox.pm    |  2 +-
 lib/PublicInbox/Search.pm  | 24 +++++++++++++-----------
 5 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 6a173f67..4df885ab 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -33,7 +33,7 @@ sub search_partial ($$) {
 	my ($ibx, $mid) = @_;
 	return if length($mid) < $MIN_PARTIAL_LEN;
 	my $srch = $ibx->search or return; # NOT ->isrch, we already try ->ALL
-	my $opt = { limit => PARTIAL_MAX, mset => 2 };
+	my $opt = { limit => PARTIAL_MAX, relevance => -1 };
 	my @try = ("m:$mid*");
 	my $chop = $mid;
 	if ($chop =~ s/(\W+)(\w*)\z//) {
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index a3a10bde..2af5ab0c 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -1136,7 +1136,7 @@ sub search_common {
 		my $srch = $self->{ibx}->isrch or
 			return "$tag BAD search not available for mailbox\r\n";
 		my $opt = {
-			mset => 2,
+			relevance => -1,
 			limit => UID_SLICE,
 			uid_range => $range_info
 		};
diff --git a/lib/PublicInbox/Isearch.pm b/lib/PublicInbox/Isearch.pm
index e362c80a..7ca2f9e4 100644
--- a/lib/PublicInbox/Isearch.pm
+++ b/lib/PublicInbox/Isearch.pm
@@ -61,7 +61,7 @@ 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}) {
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index c8e4b406..83fa7d8a 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -235,7 +235,7 @@ sub mbox_all {
 	my $over = $ctx->{ibx}->over or
 		return PublicInbox::WWW::need($ctx, 'Overview');
 
-	my $qopts = $ctx->{qopts} = { mset => 2 }; # order by docid
+	my $qopts = $ctx->{qopts} = { relevance => -1 }; # ORDER BY docid ASC
 	$qopts->{thread} = 1 if $q->{t};
 	my $mset = $srch->mset($q_string, $qopts);
 	$qopts->{offset} = $mset->size or
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index ffd19a1f..fb3e9975 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -58,7 +58,11 @@ our $QP_FLAGS;
 our %X = map { $_ => 0 } qw(BoolWeight Database Enquire QueryParser Stem Query);
 our $Xap; # 'Search::Xapian' or 'Xapian'
 our $NVRP; # '$Xap::'.('NumberValueRangeProcessor' or 'NumberRangeProcessor')
-our $ENQ_ASCENDING;
+
+# ENQ_DESCENDING and ENQ_ASCENDING weren't in SWIG Xapian.pm prior to 1.4.16,
+# let's hope the ABI is stable
+our $ENQ_DESCENDING = 0;
+our $ENQ_ASCENDING = 1;
 
 sub load_xapian () {
 	return 1 if defined $Xap;
@@ -84,12 +88,6 @@ sub load_xapian () {
 			'NumberRangeProcessor' : 'NumberValueRangeProcessor');
 		$X{$_} = $Xap.'::'.$_ for (keys %X);
 
-		# ENQ_ASCENDING doesn't seem exported by SWIG Xapian.pm,
-		# so lets hope this part of the ABI is stable because it's
-		# just an integer:
-		$ENQ_ASCENDING = $x eq 'Xapian' ?
-				1 : Search::Xapian::ENQ_ASCENDING();
-
 		*sortable_serialise = $x.'::sortable_serialise';
 		*sortable_unserialise = $x.'::sortable_unserialise';
 		# n.b. FLAG_PURE_NOT is expensive not suitable for a public
@@ -344,13 +342,17 @@ sub _enquire_once { # retry_reopen callback
 	$enquire->set_query($query);
 	$opts ||= {};
         my $desc = !$opts->{asc};
-	if (($opts->{mset} || 0) == 2) { # mset == 2: ORDER BY docid/UID
+	my $rel = $opts->{relevance} // 0;
+	if ($rel == -1) { # ORDER BY docid/UID
+		$enquire->set_weighting_scheme($X{BoolWeight}->new);
 		$enquire->set_docid_order($ENQ_ASCENDING);
+	} elsif ($rel == 0) {
+		$enquire->set_sort_by_value_then_relevance(TS, $desc);
+	} elsif ($rel == -2) {
 		$enquire->set_weighting_scheme($X{BoolWeight}->new);
-	} elsif ($opts->{relevance}) {
+		$enquire->set_docid_order($ENQ_DESCENDING);
+	} else { # rel > 0
 		$enquire->set_sort_by_relevance_then_value(TS, $desc);
-	} else {
-		$enquire->set_sort_by_value_then_relevance(TS, $desc);
 	}
 
 	# `mairix -t / --threads' or JMAP collapseThreads

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-27 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27 19:38 [PATCH 0/2] internal search parameter naming Eric Wong
2020-12-27 19:38 ` [PATCH 1/2] search: remove pointless {relevance} setting Eric Wong
2020-12-27 19:38 ` [PATCH 2/2] search: remove {mset} option for ->mset method Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git