def test_fuzzy_query_partial_match_disallowed(self): # Create a query query_compiler = self.query_compiler_class( models.Book.objects.all(), Fuzzy("Hello world"), fields=["_all"], partial_match=True, ) # Check it with self.assertRaises(NotImplementedError): query_compiler.get_inner_query()
def test_fuzzy_query(self): # Create a query query_compiler = self.query_compiler_class( models.Book.objects.all(), Fuzzy("Hello world"), partial_match=False, ) # Check it expected_result = { "match": { "_all_text": { "query": "Hello world", "fuzziness": "AUTO" } } } self.assertDictEqual(query_compiler.get_inner_query(), expected_result)