From: Amirouche Boubekki <amirouche@hypermove.net>
To: Guile User <guile-user@gnu.org>
Subject: [ANN] hyper search engine 0.2
Date: Sun, 19 Jun 2016 11:49:02 +0200 [thread overview]
Message-ID: <a2face7ace35a62caccfa46492ccc528@hypermove.net> (raw)
Héllo,
Yesterday someone on IRC asked for a new feature; the ability
to use xor/and/not/or to express queries. So here is it!
# Kesako?
The implementation is straight forward. Actually I defined
`xor*`, `and*`, `not*` and `or*` procedures that looks like
this:
```
(define* ((xor* a b) uid)
(if (procedure? a)
(if (procedure? b)
((xor* (a uid) (b uid)) uid)
((xor* (a uid) b) uid))
(if (procedure? b)
((xor* a (b uid)) uid)
(xor a b))))
```
As you can see it only accepts two arguments :(
Luckily you do no need to understand that to use it,
but it looks funny. That's why I pasted it.
Anyway, given a list of uids that you can retrieve with
`(documents db)` or `(search* db tokens ...)` you can filter
the results with the help of `(keyword db name)`:
```
(filter (and* (keyword db "hypermove") (keyword db "guile")) uids)
```
This is equivalent to `(search* db "hypermove" "guile")` but it is less
efficient!
Previously you could not for instance query the following:
```
(and* (keyword db "commercial") (or* (keyword db "hypermove") (keyword
db "gnu")))
```
Right now, `keyword` is an implementation detail. But in
the future maybe, you could think of other ways to filter
documents for instance based on some kind of ranking.
# Note on performance
Now a word on `(documents db)`. `documents` does almost
a full scan of a database... To speed things up a little,
you rely on `search*` which is faster but you have
to reword your query. For instance, the previous query,
could actually be done like that:
```
(filter (or* (keyword db "hypermove") (keyword db "gnu")) (search* db
"commercial"))
```
The documentation is up-to-date on the website:
https://framagit.org/a-guile-mind/hyper
Enjoy!
--
Amirouche ~ amz3 ~ http://www.hyperdev.fr
next reply other threads:[~2016-06-19 9:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-19 9:49 Amirouche Boubekki [this message]
2016-06-19 18:55 ` [ANN] hyper search engine 0.2 Amirouche Boubekki
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2face7ace35a62caccfa46492ccc528@hypermove.net \
--to=amirouche@hypermove.net \
--cc=guile-user@gnu.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).