[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ANN] hyper search engine 0.2
From: |
Amirouche Boubekki |
Subject: |
[ANN] hyper search engine 0.2 |
Date: |
Sun, 19 Jun 2016 11:49:02 +0200 |
User-agent: |
Roundcube Webmail/1.1.2 |
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
- [ANN] hyper search engine 0.2,
Amirouche Boubekki <=