Commit 65e0b15b authored by Skia's avatar Skia

Update Haystack indexer to use Xapian

parent c071ed66
Pipeline #1619 passed with stage
in 9 minutes and 57 seconds
......@@ -10,6 +10,6 @@ doc/html
data/
/static/
sith/settings_custom.py
sith/whoosh_index/
sith/search_indexes/
.coverage
coverage_report/
......@@ -5,7 +5,10 @@ test:
stage: test
script:
- apt-get update
- apt-get install -y gettext
- apt-get install -y gettext python3-xapian
- pushd /usr/lib/python3/dist-packages/xapian && ln -s _xapian* _xapian.so && popd
- export PYTHONPATH="/usr/lib/python3/dist-packages:$PYTHONPATH"
- python -c 'import xapian' # Fail immediately if there is a problem with xapian
- pip install -r requirements.txt
- pip install coverage
- ./manage.py compilemessages
......
......@@ -30,14 +30,14 @@ generate a complete HTML documentation that will be available in the *./doc/html
### Dependencies:
See requirements.txt
You may need to install some dev libraries like `libmysqlclient-dev`, `libssl-dev`, `libjpeg-dev`, or `zlib1g-dev` to install all the
You may need to install some dev libraries like `libmysqlclient-dev`, `libssl-dev`, `libjpeg-dev`, `python3-xapian`, or `zlib1g-dev` to install all the
requiered dependancies with pip. You may also need `mysql-client`. Don't also forget `python3-dev` if you don't have it
already.
You can check all of them with:
```
sudo apt install libmysqlclient-dev libssl-dev libjpeg-dev zlib1g-dev python3-dev libffi-dev python3-dev libgraphviz-dev pkg-config
sudo apt install libmysqlclient-dev libssl-dev libjpeg-dev zlib1g-dev python3-dev libffi-dev python3-dev libgraphviz-dev pkg-config python3-xapian
```
The development is done with sqlite, but it is advised to set a more robust DBMS for production (Postgresql for example)
......
......@@ -71,12 +71,7 @@ def notification(request, notif_id):
def search_user(query, as_json=False):
res = (
SearchQuerySet()
.models(User)
.filter(text=query)
.filter_or(text__contains=query)[:20]
)
res = SearchQuerySet().models(User).filter_or(text__contains=query)[:20]
return [r.object for r in res]
......
......@@ -184,8 +184,9 @@ TEMPLATES = [
HAYSTACK_CONNECTIONS = {
"default": {
"ENGINE": "haystack.backends.whoosh_backend.WhooshEngine",
"PATH": os.path.join(os.path.dirname(__file__), "whoosh_index"),
"ENGINE": "xapian_backend.XapianEngine",
"PATH": os.path.join(os.path.dirname(__file__), "search_indexes", "xapian"),
"INCLUDE_SPELLING": True,
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment