From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Any package for boolean search? Date: Fri, 27 Dec 2024 14:05:40 +0300 Message-ID: References: <86a5cjdlrv.fsf@gmail.com> <86v7v6avg8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39766"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.12 (2023-09-09) Cc: Help GNU Emacs To: Joel Reicher Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 27 12:06:20 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tR8Ae-000ADE-49 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 27 Dec 2024 12:06:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tR8A9-0003wd-BU; Fri, 27 Dec 2024 06:05:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tR8A7-0003wD-FB for help-gnu-emacs@gnu.org; Fri, 27 Dec 2024 06:05:47 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tR8A5-0004fb-PE for help-gnu-emacs@gnu.org; Fri, 27 Dec 2024 06:05:47 -0500 Original-Received: from localhost ([::ffff:41.75.190.33]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000007DCBA.00000000676E8A07.001273BD; Fri, 27 Dec 2024 04:05:42 -0700 Mail-Followup-To: Joel Reicher , Help GNU Emacs Content-Disposition: inline In-Reply-To: <86v7v6avg8.fsf@gmail.com> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:149023 Archived-At: * Joel Reicher [2024-12-27 02:16]: > Jean Louis writes: > > > * Joel Reicher [2024-12-26 09:03]: > > [...] > > > > Is there an Emacs or elisp aspect to this question I might be > > > missing? > > > > I don't know what you mean. I am looking for some ready package that > > provides maybe string searching within other strings, by using boolean > > operators. > > Why are you expecting this to be a package? Strings are a native/primitive > elisp datatype. Thanks, though, I do not expect, I am asking if someone knows about it. Those AND, OR, NOT are pretty classic, not so? > (info "(elisp) Text Comparison") I can't find there anything related, sure as basic functions is very useful, but doesn't parse the query. - cat dog -- I would use this with AND automatically; but maybe add OR on the end of results; - cat and dog -- this is ONLY AND, without OR results - cat dog OR giraffe in Africa -- here I would parse it as: - cat AND dog -- is it there? - but it can be also "giraffe AND Africa" There are too many combinations and I have to make it so that I can first parse the query into smaller pieces. Then this query is dispatched to more basic functions. > and also string-match at (info "(elisp) Regexp Search") Sure! Thanks much. I am using those functions and it is useful let's say, if I need to search with "OR" some few words. But what if there are complex queries: cat plays with dog OR dog plays with dogs NOT giraffe or maybe this way: (cat plays with dog) OR (dog plays with dogs) NOT giraffe Then I have to parse it, separate it: - NOT giraffe - is there any result for cat? But no giraffe - or any result for dog? But no giraffe I hope you understand the meaning by that example. It is called Boolean query parser, but when I started this question I did not know the title. Now I know it. Here is example in PHP skipperbent/pecee-boolean-query-parser: Convert a boolean search query into a query that is compatible with a fulltext search. https://github.com/skipperbent/pecee-boolean-query-parser As there is apparently no such ready package in Emacs, then I will go slow and start with functional examples: 1. For any query, find all occurences matching exactly; for query "cat plays" it will find "Cat plays with ball" 2. Parse words and find all occurences matching same words but with AND: for query "cat plays" it will also find "Cat likes doggy which plays with the ball" Then I can think from there how to develop OR and NOT. -- Jean Louis