Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
adb15372d8
|
@ -92,6 +92,8 @@ The backend has the following optional settings:
|
||||||
See `here <http://xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html#ac7dc3b55b6083bd3ff98fc8b2726c8fd>`__ for
|
See `here <http://xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html#ac7dc3b55b6083bd3ff98fc8b2726c8fd>`__ for
|
||||||
more information about the different strategies.
|
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.
|
- ``HAYSTACK_XAPIAN_USE_LOCKFILE``: Use a lockfile to prevent database locking errors when running management commands with multiple workers.
|
||||||
Defaults to `True`.
|
Defaults to `True`.
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ from haystack.inputs import AutoQuery
|
||||||
from haystack.models import SearchResult
|
from haystack.models import SearchResult
|
||||||
from haystack.utils import get_identifier, get_model_ct
|
from haystack.utils import get_identifier, get_model_ct
|
||||||
|
|
||||||
NGRAM_MIN_LENGTH = 2
|
NGRAM_MIN_LENGTH = getattr(settings, 'XAPIAN_NGRAM_MIN_LENGTH', 2)
|
||||||
NGRAM_MAX_LENGTH = 15
|
NGRAM_MAX_LENGTH = getattr(settings, 'XAPIAN_NGRAM_MAX_LENGTH', 15)
|
||||||
|
|
||||||
LONG_TERM = re.compile(b'[^\s]{239,}')
|
LONG_TERM = re.compile(b'[^\s]{239,}')
|
||||||
LONG_TERM_METHOD = getattr(settings, 'XAPIAN_LONG_TERM_METHOD', 'truncate')
|
LONG_TERM_METHOD = getattr(settings, 'XAPIAN_LONG_TERM_METHOD', 'truncate')
|
||||||
|
@ -134,7 +134,7 @@ class XHValueRangeProcessor(xapian.ValueRangeProcessor):
|
||||||
begin = -sys.maxsize - 1
|
begin = -sys.maxsize - 1
|
||||||
elif field_type == 'float':
|
elif field_type == 'float':
|
||||||
begin = float('-inf')
|
begin = float('-inf')
|
||||||
elif field_type == 'date' or field_type == 'datetime':
|
elif field_type in ['date', 'datetime']:
|
||||||
begin = '00010101000000'
|
begin = '00010101000000'
|
||||||
elif end == '*':
|
elif end == '*':
|
||||||
if field_type == 'text':
|
if field_type == 'text':
|
||||||
|
@ -143,7 +143,7 @@ class XHValueRangeProcessor(xapian.ValueRangeProcessor):
|
||||||
end = sys.maxsize
|
end = sys.maxsize
|
||||||
elif field_type == 'float':
|
elif field_type == 'float':
|
||||||
end = float('inf')
|
end = float('inf')
|
||||||
elif field_type == 'date' or field_type == 'datetime':
|
elif field_type in ['date', 'datetime']:
|
||||||
end = '99990101000000'
|
end = '99990101000000'
|
||||||
|
|
||||||
if field_type == 'float':
|
if field_type == 'float':
|
||||||
|
@ -1616,7 +1616,7 @@ def _term_to_xapian_value(term, field_type):
|
||||||
value = INTEGER_FORMAT % term
|
value = INTEGER_FORMAT % term
|
||||||
elif field_type == 'float':
|
elif field_type == 'float':
|
||||||
value = xapian.sortable_serialise(term)
|
value = xapian.sortable_serialise(term)
|
||||||
elif field_type == 'date' or field_type == 'datetime':
|
elif field_type in ['date', 'datetime']:
|
||||||
if field_type == 'date':
|
if field_type == 'date':
|
||||||
# http://stackoverflow.com/a/1937636/931303 and comments
|
# http://stackoverflow.com/a/1937636/931303 and comments
|
||||||
term = datetime.datetime.combine(term, datetime.time())
|
term = datetime.datetime.combine(term, datetime.time())
|
||||||
|
@ -1679,7 +1679,7 @@ def _from_xapian_value(value, field_type):
|
||||||
return int(value)
|
return int(value)
|
||||||
elif field_type == 'float':
|
elif field_type == 'float':
|
||||||
return xapian.sortable_unserialise(value)
|
return xapian.sortable_unserialise(value)
|
||||||
elif field_type == 'date' or field_type == 'datetime':
|
elif field_type in ['date', 'datetime']:
|
||||||
datetime_value = datetime.datetime.strptime(value, DATETIME_FORMAT)
|
datetime_value = datetime.datetime.strptime(value, DATETIME_FORMAT)
|
||||||
if field_type == 'datetime':
|
if field_type == 'datetime':
|
||||||
return datetime_value
|
return datetime_value
|
||||||
|
|
Loading…
Reference in New Issue