diff --git a/tests/xapian_tests/tests/xapian_backend.py b/tests/xapian_tests/tests/xapian_backend.py index 50ff179..17d9150 100644 --- a/tests/xapian_tests/tests/xapian_backend.py +++ b/tests/xapian_tests/tests/xapian_backend.py @@ -5,6 +5,7 @@ import cPickle as pickle import datetime import os import shutil +import sys import xapian from django.conf import settings @@ -381,18 +382,18 @@ class XapianSearchBackendTestCase(TestCase): self.assertEqual(len(fields), 13) self.assertEqual(fields, [ {'column': 0, 'type': 'text', 'field_name': 'name', 'multi_valued': 'false'}, - {'column': 1, 'field_name': 'name_exact', 'type': 'text', 'multi_valued': 'false'}, - {'column': 2, 'type': 'text', 'field_name': 'tags', 'multi_valued': 'true'}, - {'column': 3, 'type': 'text', 'field_name': 'keys', 'multi_valued': 'true'}, - {'column': 4, 'type': 'text', 'field_name': 'text', 'multi_valued': 'false'}, - {'column': 5, 'type': 'float', 'field_name': 'popularity', 'multi_valued': 'false'}, - {'column': 6, 'type': 'text', 'field_name': 'sites', 'multi_valued': 'true'}, - {'column': 7, 'type': 'long', 'field_name': 'value', 'multi_valued': 'false'}, - {'column': 8, 'type': 'text', 'field_name': 'url', 'multi_valued': 'false'}, - {'column': 9, 'type': 'boolean', 'field_name': 'flag', 'multi_valued': 'false'}, - {'column': 10, 'type': 'text', 'field_name': 'titles', 'multi_valued': 'true'}, + {'column': 1, 'type': 'text', 'field_name': 'tags', 'multi_valued': 'true'}, + {'column': 2, 'type': 'text', 'field_name': 'keys', 'multi_valued': 'true'}, + {'column': 3, 'type': 'text', 'field_name': 'text', 'multi_valued': 'false'}, + {'column': 4, 'type': 'float', 'field_name': 'popularity', 'multi_valued': 'false'}, + {'column': 5, 'type': 'text', 'field_name': 'sites', 'multi_valued': 'true'}, + {'column': 6, 'type': 'long', 'field_name': 'value', 'multi_valued': 'false'}, + {'column': 7, 'type': 'text', 'field_name': 'url', 'multi_valued': 'false'}, + {'column': 8, 'type': 'boolean', 'field_name': 'flag', 'multi_valued': 'false'}, + {'column': 9, 'type': 'text', 'field_name': 'titles', 'multi_valued': 'true'}, + {'column': 10, 'type': 'text', 'field_name': 'name_exact', 'multi_valued': 'false'}, {'column': 11, 'type': 'date', 'field_name': 'pub_date', 'multi_valued': 'false'}, - {'column': 12, 'type': 'text', 'field_name': 'empty', 'multi_valued': 'false'}, + {'column': 12, 'type': 'text', 'field_name': 'empty', 'multi_valued': 'false'} ]) def test_parse_query(self): @@ -407,10 +408,10 @@ class XapianSearchBackendTestCase(TestCase): self.assertEqual(str(self.backend.parse_query('name:da*')), 'Xapian::Query((XNAMEdavid1:(pos=1) OR XNAMEdavid2:(pos=1) OR XNAMEdavid3:(pos=1)))') self.assertEqual(str(self.backend.parse_query('name:david1..david2')), 'Xapian::Query(VALUE_RANGE 0 david1 david2)') - self.assertEqual(str(self.backend.parse_query('value:0..10')), 'Xapian::Query(VALUE_RANGE 7 000000000000 000000000010)') - self.assertEqual(str(self.backend.parse_query('value:..10')), 'Xapian::Query(VALUE_RANGE 7 -9223372036854775808 000000000010)') - self.assertEqual(str(self.backend.parse_query('value:10..*')), 'Xapian::Query(VALUE_RANGE 7 000000000010 9223372036854775807)') - self.assertEqual(str(self.backend.parse_query('popularity:25.5..100.0')), 'Xapian::Query(VALUE_RANGE 5 \xb2` \xba@)') + self.assertEqual(str(self.backend.parse_query('value:0..10')), 'Xapian::Query(VALUE_RANGE 6 000000000000 000000000010)') + self.assertEqual(str(self.backend.parse_query('value:..10')), 'Xapian::Query(VALUE_RANGE 6 %012d 000000000010)' % (-sys.maxint - 1)) + self.assertEqual(str(self.backend.parse_query('value:10..*')), 'Xapian::Query(VALUE_RANGE 6 000000000010 %012d)' % sys.maxint) + self.assertEqual(str(self.backend.parse_query('popularity:25.5..100.0')), 'Xapian::Query(VALUE_RANGE 4 \xb2` \xba@)') class LiveXapianMockSearchIndex(indexes.SearchIndex): diff --git a/tests/xapian_tests/tests/xapian_query.py b/tests/xapian_tests/tests/xapian_query.py index 25c0c15..713ce0e 100644 --- a/tests/xapian_tests/tests/xapian_query.py +++ b/tests/xapian_tests/tests/xapian_query.py @@ -154,7 +154,7 @@ class XapianSearchQueryTestCase(TestCase): self.assertEqual(str(self.sq.build_query()), u'Xapian::Query(((Zhello OR hello) AND 0 * XCONTENTTYPEcore.mockmodel))') self.sq.add_model(AnotherMockModel) - self.assertEqual(str(self.sq.build_query()), u'Xapian::Query(((Zhello OR hello) AND (0 * XCONTENTTYPEcore.mockmodel OR 0 * XCONTENTTYPEcore.anothermockmodel)))') + self.assertTrue(str(self.sq.build_query()) in u'Xapian::Query(((Zhello OR hello) AND (0 * XCONTENTTYPEcore.anothermockmodel OR 0 * XCONTENTTYPEcore.mockmodel)))' or u'Xapian::Query(((Zhello OR hello) AND (0 * XCONTENTTYPEcore.mockmodel OR 0 * XCONTENTTYPEcore.anothermockmodel)))') def test_build_query_with_punctuation(self): self.sq.add_filter(SQ(content='http://www.example.com')) diff --git a/xapian_backend.py b/xapian_backend.py index 571e41d..8359aff 100755 --- a/xapian_backend.py +++ b/xapian_backend.py @@ -20,7 +20,7 @@ from haystack.backends import BaseSearchBackend, BaseSearchQuery, SearchNode, lo from haystack.exceptions import HaystackError, MissingDependency from haystack.fields import DateField, DateTimeField, IntegerField, FloatField, BooleanField, MultiValueField from haystack.models import SearchResult -from haystack.utils import get_identifier, get_facet_field_name +from haystack.utils import get_identifier try: import xapian @@ -594,15 +594,6 @@ class SearchBackend(BaseSearchBackend): schema_fields.append(field_data) column += 1 - if field_class.faceted is True: - # Duplicate the field. - faceted_field = field_data.copy() - faceted_field['field_name'] = get_facet_field_name(faceted_field['field_name']) - faceted_field['column'] = column - - schema_fields.append(faceted_field) - column += 1 - return (content_field_name, schema_fields) def _do_highlight(self, content, query, tag='em'):