mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Update Haystack indexer to use Xapian
This commit is contained in:
parent
c071ed66bc
commit
65e0b15b31
2
.gitignore
vendored
2
.gitignore
vendored
@ -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]
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ phonenumbers
|
||||
django-ajax-selects
|
||||
reportlab
|
||||
django-haystack
|
||||
whoosh
|
||||
xapian-haystack
|
||||
django-debug-toolbar
|
||||
libsass
|
||||
django-ordered-model
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user