diff --git a/.gitignore b/.gitignore index 76fd8b83..1859caab 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,6 @@ doc/html data/ /static/ sith/settings_custom.py -sith/whoosh_index/ +sith/search_indexes/ .coverage coverage_report/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 57f7f4ec..216837bc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/README.md b/README.md index f8eed93d..fb459574 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/core/views/site.py b/core/views/site.py index 55c26608..282156d6 100644 --- a/core/views/site.py +++ b/core/views/site.py @@ -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] diff --git a/requirements.txt b/requirements.txt index 0d3d01ac..2efe3c6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ phonenumbers django-ajax-selects reportlab django-haystack -whoosh +xapian-haystack django-debug-toolbar libsass django-ordered-model diff --git a/sith/settings.py b/sith/settings.py index 2991efe8..07532a4c 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -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, } }