Drop code meant to support Xapian 1.2.x, 1.3.x.
xapian-haystack now lists xapian 1.4.x as the minimum supported version, so we don't need to carry around code to support 1.2.x anymore.
This commit is contained in:
parent
1a5b4cf0b3
commit
4a952bb7f9
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# first argument of the script is Xapian version (e.g. 1.2.19)
|
||||
# first argument of the script is Xapian version (e.g. 1.4.18)
|
||||
|
||||
VERSION=$1
|
||||
|
||||
|
@ -31,12 +31,6 @@ cd $VIRTUAL_ENV/packages/${CORE}
|
|||
|
||||
PYTHON_FLAG=--with-python3
|
||||
|
||||
if [ $VERSION = "1.3.3" ]; then
|
||||
XAPIAN_CONFIG=$VIRTUAL_ENV/bin/xapian-config-1.3
|
||||
else
|
||||
XAPIAN_CONFIG=
|
||||
fi
|
||||
|
||||
# The bindings for Python require python-sphinx
|
||||
echo "Installing Python-Sphinx..."
|
||||
SPHINX2_FIXED_VERSION=1.4.12
|
||||
|
@ -48,7 +42,7 @@ fi
|
|||
|
||||
echo "Installing Xapian-bindings..."
|
||||
cd $VIRTUAL_ENV/packages/${BINDINGS}
|
||||
./configure --prefix=$VIRTUAL_ENV $PYTHON_FLAG XAPIAN_CONFIG=$XAPIAN_CONFIG && make && make install
|
||||
./configure --prefix=$VIRTUAL_ENV $PYTHON_FLAG && make && make install
|
||||
|
||||
# clean
|
||||
cd $VIRTUAL_ENV
|
||||
|
|
|
@ -78,7 +78,7 @@ class HaystackBackendTestCase:
|
|||
self.backend.clear()
|
||||
connections['default']._index = self.old_ui
|
||||
|
||||
def assertExpectedQuery(self, query, string_or_list, xapian12string=''):
|
||||
def assertExpectedQuery(self, query, string_or_list):
|
||||
if isinstance(string_or_list, list):
|
||||
strings = string_or_list
|
||||
else:
|
||||
|
@ -86,12 +86,6 @@ class HaystackBackendTestCase:
|
|||
|
||||
expected = ['Query(%s)' % string for string in strings]
|
||||
|
||||
if XAPIAN_VERSION[1] <= 2:
|
||||
if xapian12string:
|
||||
expected = ['Xapian::Query(%s)' % xapian12string]
|
||||
else:
|
||||
expected = ['Xapian::Query(%s)' % string for string in strings]
|
||||
|
||||
self.assertIn(str(query), expected)
|
||||
|
||||
|
||||
|
@ -607,11 +601,9 @@ class BackendFeaturesTestCase(HaystackBackendTestCase, TestCase):
|
|||
])
|
||||
|
||||
def test_parse_query(self):
|
||||
self.assertExpectedQuery(self.backend.parse_query('indexed'), 'Zindex@1',
|
||||
xapian12string='Zindex:(pos=1)')
|
||||
self.assertExpectedQuery(self.backend.parse_query('indexed'), 'Zindex@1')
|
||||
|
||||
self.assertExpectedQuery(self.backend.parse_query('name:david'),
|
||||
'ZXNAMEdavid@1', xapian12string='ZXNAMEdavid:(pos=1)')
|
||||
self.assertExpectedQuery(self.backend.parse_query('name:david'), 'ZXNAMEdavid@1')
|
||||
|
||||
if xapian.minor_version() >= 2:
|
||||
# todo: why `SYNONYM WILDCARD OR XNAMEda`?
|
||||
|
@ -620,10 +612,7 @@ class BackendFeaturesTestCase(HaystackBackendTestCase, TestCase):
|
|||
[
|
||||
'(SYNONYM WILDCARD OR XNAMEda)',
|
||||
'WILDCARD SYNONYM XNAMEda',
|
||||
],
|
||||
xapian12string='(XNAMEdavid1:(pos=1) SYNONYM '
|
||||
'XNAMEdavid2:(pos=1) SYNONYM '
|
||||
'XNAMEdavid3:(pos=1))')
|
||||
])
|
||||
else:
|
||||
self.assertEqual(str(self.backend.parse_query('name:da*')),
|
||||
'Xapian::Query(('
|
||||
|
@ -636,26 +625,22 @@ class BackendFeaturesTestCase(HaystackBackendTestCase, TestCase):
|
|||
[
|
||||
'0 * VALUE_RANGE 9 david1 david2',
|
||||
'VALUE_RANGE 9 david1 david2',
|
||||
],
|
||||
xapian12string='VALUE_RANGE 9 david1 david2')
|
||||
])
|
||||
self.assertExpectedQuery(self.backend.parse_query('number:0..10'),
|
||||
[
|
||||
'0 * VALUE_RANGE 11 000000000000 000000000010',
|
||||
'VALUE_RANGE 11 000000000000 000000000010',
|
||||
],
|
||||
xapian12string='VALUE_RANGE 11 000000000000 000000000010')
|
||||
])
|
||||
self.assertExpectedQuery(self.backend.parse_query('number:..10'),
|
||||
[
|
||||
'0 * VALUE_RANGE 11 %012d 000000000010' % (-sys.maxsize - 1),
|
||||
'VALUE_RANGE 11 %012d 000000000010' % (-sys.maxsize - 1),
|
||||
],
|
||||
xapian12string='VALUE_RANGE 11 %012d 000000000010' % (-sys.maxsize - 1))
|
||||
])
|
||||
self.assertExpectedQuery(self.backend.parse_query('number:10..*'),
|
||||
[
|
||||
'0 * VALUE_RANGE 11 000000000010 %012d' % sys.maxsize,
|
||||
'VALUE_RANGE 11 000000000010 %012d' % sys.maxsize,
|
||||
],
|
||||
xapian12string='VALUE_RANGE 11 000000000010 %012d' % sys.maxsize)
|
||||
])
|
||||
|
||||
def test_order_by_django_id(self):
|
||||
"""
|
||||
|
|
|
@ -70,17 +70,12 @@ class XapianSearchQueryTestCase(HaystackBackendTestCase, TestCase):
|
|||
self.sq.add_filter(SQ(content=datetime.datetime(2009, 5, 8, 11, 28)))
|
||||
self.assertExpectedQuery(self.sq.build_query(),
|
||||
'((Z2009-05-08 OR 2009-05-08) OR'
|
||||
' (Z11:28:00 OR 11:28:00))',
|
||||
xapian12string='(Z2009-05-08 OR 2009-05-08 OR'
|
||||
' Z11:28:00 OR 11:28:00)')
|
||||
' (Z11:28:00 OR 11:28:00))')
|
||||
|
||||
def test_datetime_not(self):
|
||||
self.sq.add_filter(~SQ(content=datetime.datetime(2009, 5, 8, 11, 28)))
|
||||
self.assertExpectedQuery(self.sq.build_query(),
|
||||
'(<alldocuments> AND_NOT ((Z2009-05-08 OR 2009-05-08) OR (Z11:28:00 OR 11:28:00)))',
|
||||
xapian12string='(<alldocuments> AND_NOT '
|
||||
'(Z2009-05-08 OR 2009-05-08 OR'
|
||||
' Z11:28:00 OR 11:28:00))')
|
||||
'(<alldocuments> AND_NOT ((Z2009-05-08 OR 2009-05-08) OR (Z11:28:00 OR 11:28:00)))')
|
||||
|
||||
def test_float(self):
|
||||
self.sq.add_filter(SQ(content=25.52))
|
||||
|
@ -103,8 +98,7 @@ class XapianSearchQueryTestCase(HaystackBackendTestCase, TestCase):
|
|||
self.sq.add_filter(SQ(content='hello') | SQ(content='world'))
|
||||
self.assertExpectedQuery(
|
||||
self.sq.build_query(),
|
||||
'((Zhello OR hello) OR (Zworld OR world))',
|
||||
xapian12string='(Zhello OR hello OR Zworld OR world)')
|
||||
'((Zhello OR hello) OR (Zworld OR world))')
|
||||
|
||||
def test_multiple_words_or_not(self):
|
||||
self.sq.add_filter(~SQ(content='hello') | ~SQ(content='world'))
|
||||
|
@ -118,9 +112,7 @@ class XapianSearchQueryTestCase(HaystackBackendTestCase, TestCase):
|
|||
self.assertExpectedQuery(
|
||||
self.sq.build_query(),
|
||||
'(((Zwhi OR why) OR (Zhello OR hello)) AND '
|
||||
'(<alldocuments> AND_NOT (Zworld OR world)))',
|
||||
xapian12string='((Zwhi OR why OR Zhello OR hello) AND'
|
||||
' (<alldocuments> AND_NOT (Zworld OR world)))',)
|
||||
'(<alldocuments> AND_NOT (Zworld OR world)))')
|
||||
|
||||
def test_multiple_word_field_exact(self):
|
||||
self.sq.add_filter(SQ(foo='hello'))
|
||||
|
@ -139,15 +131,13 @@ class XapianSearchQueryTestCase(HaystackBackendTestCase, TestCase):
|
|||
def test_or(self):
|
||||
self.sq.add_filter(SQ(content='hello world'))
|
||||
self.assertExpectedQuery(
|
||||
self.sq.build_query(), '((Zhello OR hello) OR (Zworld OR world))',
|
||||
xapian12string='(Zhello OR hello OR Zworld OR world)')
|
||||
self.sq.build_query(), '((Zhello OR hello) OR (Zworld OR world))')
|
||||
|
||||
def test_not_or(self):
|
||||
self.sq.add_filter(~SQ(content='hello world'))
|
||||
self.assertExpectedQuery(
|
||||
self.sq.build_query(),
|
||||
'(<alldocuments> AND_NOT ((Zhello OR hello) OR (Zworld OR world)))',
|
||||
xapian12string='(<alldocuments> AND_NOT (Zhello OR hello OR Zworld OR world))')
|
||||
'(<alldocuments> AND_NOT ((Zhello OR hello) OR (Zworld OR world)))')
|
||||
|
||||
def test_boost(self):
|
||||
self.sq.add_filter(SQ(content='hello'))
|
||||
|
|
|
@ -285,11 +285,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
term_generator = xapian.TermGenerator()
|
||||
term_generator.set_database(database)
|
||||
term_generator.set_stemmer(xapian.Stem(self.language))
|
||||
try:
|
||||
term_generator.set_stemming_strategy(self.stemming_strategy)
|
||||
except AttributeError:
|
||||
# Versions before Xapian 1.2.11 do not support stemming strategies for TermGenerator
|
||||
pass
|
||||
term_generator.set_stemming_strategy(self.stemming_strategy)
|
||||
if self.include_spelling is True:
|
||||
term_generator.set_flags(xapian.TermGenerator.FLAG_SPELLING)
|
||||
|
||||
|
|
Loading…
Reference in New Issue