From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:41419) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7akd-00039B-Jw for guix-patches@gnu.org; Fri, 28 Feb 2020 03:12:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7akc-0003Ld-F7 for guix-patches@gnu.org; Fri, 28 Feb 2020 03:12:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:54635) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7akc-0003LX-Ch for guix-patches@gnu.org; Fri, 28 Feb 2020 03:12:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j7akc-0005hx-8l for guix-patches@gnu.org; Fri, 28 Feb 2020 03:12:02 -0500 Subject: [bug#39258] [PATCH 4/4] gnu: Use xapian index for package search. Resent-Message-ID: From: Pierre Neidhardt References: <20200227204150.30985-1-arunisaac@systemreboot.net> <20200227204150.30985-5-arunisaac@systemreboot.net> Date: Fri, 28 Feb 2020 09:11:31 +0100 In-Reply-To: <20200227204150.30985-5-arunisaac@systemreboot.net> (Arun Isaac's message of "Fri, 28 Feb 2020 02:11:50 +0530") Message-ID: <87h7zb5dxo.fsf@ambrevar.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Arun Isaac Cc: ludo@gnu.org, 39258@debbugs.gnu.org, zimon.toutoune@gmail.com --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Arun Isaac writes: > @@ -453,6 +454,20 @@ reducing the memory footprint." >=20=20 > db-path) >=20=20 > +(define (search-package-index profile querystring) Maybe `query-string'? > > --- a/guix/scripts/package.scm > +++ b/guix/scripts/package.scm > @@ -7,6 +7,7 @@ > ;;; Copyright =C2=A9 2016 Benz Schenk > ;;; Copyright =C2=A9 2016 Chris Marusich > ;;; Copyright =C2=A9 2019 Tobias Geerinckx-Rice > +;;; Copyright =C2=A9 2020 Arun Isaac > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -178,31 +179,40 @@ hooks\" run when building the profile." > ;;; Package specifications. > ;;; >=20=20 > -(define (find-packages-by-description regexps) > +(define (find-packages-by-description patterns) > "Return a list of pairs: packages whose name, synopsis, description, > or output matches at least one of REGEXPS sorted by relevance, and its > non-zero relevance score." Need to update the docstring. > - (let ((matches (fold-packages (lambda (package result) > - (if (package-superseded package) > - result > - (match (package-relevance package > - regexps) > - ((? zero?) > - result) > - (score > - (cons (cons package score) > - result))))) > - '()))) > - (sort matches > - (lambda (m1 m2) > - (match m1 > - ((package1 . score1) > - (match m2 > - ((package2 . score2) > - (if (=3D score1 score2) > - (string>? (package-full-name package1) > - (package-full-name package2)) > - (> score1 score2)))))))))) > + (define (regexp? str) > + (string-any > + (char-set #\. #\[ #\{ #\} #\( #\) #\\ #\* #\+ #\? #\| #\^ #\$) > + str)) > + > + (if (and (current-profile) > + (not (any regexp? patterns))) I would not put characters like ".", "$", or "+" here, lest we mistake a Xapian pattern for a regexp. As you said, I don't think both are compatible without ambiguity anyways, so we should probably drop regexp (or at least toggle them with a command line argument). =2D-=20 Pierre Neidhardt https://ambrevar.xyz/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAl5YyzMACgkQm9z0l6S7 zH8myAf/dd2HZVdNaDmPZ/rEzf9eveD0wrhxS4pEwO8lJyBnobVHXfzcpDQ5ZjRx u/ZWqMIjbmjz8VFAPvQGMDIxQubxoDXii5ps94ZQNgitlhJfb4qq8REHC5rhuZHY bGxq4qTGKQYCXC3Yakg/uhRlQH4PhYvhVZDgWreJ2ay19JQV4fnfDeshdCq/oAUW IGti/XiBt50KWOBmRIctI3hYhEdA1mISQqh4RoPA9xKEQvnWSwS5hs1OZwcRCzGi mL3tgY7OKOmlojVVDCVo/r8Q9oXKlNiy+/sSilGCvO5AbsyFMsE3DqFYbQdFKpZq wFyI6XkXFHHmiKSVgYLct89Qc5Lgiw== =tOlQ -----END PGP SIGNATURE----- --=-=-=--