def test_query__in_empty_list(self):
"""Confirm that an empty list avoids a Elasticsearch exception"""
sqs = SearchQuerySet(using='default').filter(id__in=[])
self.assertEqual(sqs.query.build_query(), u'id:(!*:*)')
# class ElasticsearchSearchQuerySpatialBeforeReleaseTestCase(TestCase):
# def setUp(self):
# super(ElasticsearchSearchQuerySpatialBeforeReleaseTestCase, self).setUp()
# self.backend = connections['default'].get_backend()
# self._elasticsearch_version = elasticsearch.VERSION
# elasticsearch.VERSION = (0,9,9)
# def tearDown(self):
# elasticsearch.VERSION = self._elasticsearch_version
# def test_build_query_with_dwithin_range(self):
# """
# Test build_search_kwargs with dwithin range for Elasticsearch versions < 1.0.0
# """
# search_kwargs = self.backend.build_search_kwargs('where', dwithin={
# 'field': "location_field",
# 'point': Point(1.2345678, 2.3456789),
# 'distance': D(m=500)
# })
# self.assertEqual(search_kwargs['query']['filtered']['filter']['bool']['must'][1]['geo_distance'], {'distance': 0.5, 'location_field': {'lat': 2.3456789, 'lon': 1.2345678}})
# class ElasticsearchSearchQuerySpatialAfterReleaseTestCase(TestCase):
# def setUp(self):
# super(ElasticsearchSearchQuerySpatialAfterReleaseTestCase, self).setUp()
# self.backend = connections['elasticsearch'].get_backend()
# self._elasticsearch_version = elasticsearch.VERSION
# elasticsearch.VERSION = (1,0,0)
# def tearDown(self):
# elasticsearch.VERSION = self._elasticsearch_version
# def test_build_query_with_dwithin_range(self):
# """
# Test build_search_kwargs with dwithin range for Elasticsearch versions >= 1.0.0
# """
# search_kwargs = self.backend.build_search_kwargs('where', dwithin={
# 'field': "location_field",
# 'point': Point(1.2345678, 2.3456789),
# 'distance': D(m=500)
# })
# self.assertEqual(search_kwargs['query']['filtered']['filter']['bool']['must'][1]['geo_distance'], {'distance': "0.500000km", 'location_field': {'lat': 2.3456789, 'lon': 1.2345678}})