all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Joel Reicher <joel.reicher@gmail.com>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Any package for boolean search?
Date: Fri, 27 Dec 2024 14:05:40 +0300	[thread overview]
Message-ID: <Z26KBPXZyrGbJnJj@lco2> (raw)
In-Reply-To: <86v7v6avg8.fsf@gmail.com>

* Joel Reicher <joel.reicher@gmail.com> [2024-12-27 02:16]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > * Joel Reicher <joel.reicher@gmail.com> [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



  reply	other threads:[~2024-12-27 11:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-25 10:01 Any package for boolean search? Jean Louis
2024-12-25 16:21 ` [External] : " Drew Adams
2024-12-26  0:15   ` Jean Louis
2024-12-26  6:02 ` Joel Reicher
2024-12-26 10:58   ` Jean Louis
2024-12-26 23:14     ` Joel Reicher
2024-12-27 11:05       ` Jean Louis [this message]
2024-12-28  3:44         ` Joel Reicher
2024-12-26 11:00   ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z26KBPXZyrGbJnJj@lco2 \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=joel.reicher@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.