def test_range_filter(self): """ Make sure that ranges can be used in field_dictionary and filter_dictionary """ self.searcher.index("test_doc", [{ "id": "FAKE_ID_1", "test_value": "1", "age": 20 }]) self.searcher.index("test_doc", [{ "id": "FAKE_ID_2", "test_value": "2", "age": 30 }]) self.searcher.index("test_doc", [{ "id": "FAKE_ID_3", "test_value": "3", "not_age": 40 }]) response = self.searcher.search() self.assertEqual(response["total"], 3) response = self.searcher.search( field_dictionary={"age": ValueRange(19, 29)}) self.assertEqual(response["total"], 1) response = self.searcher.search( filter_dictionary={"age": ValueRange(19, 29)}) self.assertEqual(response["total"], 2)
def test_age_range_filter(begin, end, expect): """ repeated operations consolidated for tests """ response = self.searcher.search( filter_dictionary={"age": ValueRange(begin, end)}) self.assertEqual(response["total"], expect)