diff --git a/README.rst b/README.rst index 581b0d4..ebd6e87 100644 --- a/README.rst +++ b/README.rst @@ -92,6 +92,8 @@ The backend has the following optional settings: See `here `__ for more information about the different strategies. +- ``XAPIAN_NGRAM_MIN_LENGTH``, ``XAPIAN_NGRAM_MAX_LENGTH``: options for custom configuration of ngrams (phrases) length. + - ``HAYSTACK_XAPIAN_USE_LOCKFILE``: Use a lockfile to prevent database locking errors when running management commands with multiple workers. Defaults to `True`. diff --git a/xapian_backend.py b/xapian_backend.py index fd1e2d3..d6a92bb 100755 --- a/xapian_backend.py +++ b/xapian_backend.py @@ -19,8 +19,8 @@ from haystack.inputs import AutoQuery from haystack.models import SearchResult from haystack.utils import get_identifier, get_model_ct -NGRAM_MIN_LENGTH = 2 -NGRAM_MAX_LENGTH = 15 +NGRAM_MIN_LENGTH = getattr(settings, 'XAPIAN_NGRAM_MIN_LENGTH', 2) +NGRAM_MAX_LENGTH = getattr(settings, 'XAPIAN_NGRAM_MAX_LENGTH', 15) try: import xapian