@@ -221,13 +221,13 @@ def test_search_autocomplete(self):
221221 fuzzy = {"maxEdits" : 2 },
222222 )
223223 )
224- self .assertCountEqual (qs . all , [self .article ])
224+ self .assertCountEqual (qs , [self .article ])
225225
226226 def test_search_autocomplete_embedded_model (self ):
227227 qs = Article .objects .annotate (
228228 score = SearchAutocomplete (path = "writer__name" , query = "Joselina" )
229229 )
230- self .assertCountEqual (qs . all , [self .article ])
230+ self .assertCountEqual (qs , [self .article ])
231231
232232 def test_constant_score (self ):
233233 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
@@ -240,7 +240,7 @@ def test_constant_score(self):
240240 score = constant_score ,
241241 )
242242 )
243- self .assertCountEqual (qs . all , [self .article ])
243+ self .assertCountEqual (qs , [self .article ])
244244 scored = qs .first ()
245245 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
246246
@@ -268,12 +268,12 @@ def setUp(self):
268268
269269 def test_search_exists (self ):
270270 qs = Article .objects .annotate (score = SearchExists (path = "body" ))
271- self .assertCountEqual (qs . all , [self .article ])
271+ self .assertCountEqual (qs , [self .article ])
272272
273273 def test_constant_score (self ):
274274 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
275275 qs = Article .objects .annotate (score = SearchExists (path = "body" , score = constant_score ))
276- self .assertCountEqual (qs . all , [self .article ])
276+ self .assertCountEqual (qs , [self .article ])
277277 scored = qs .first ()
278278 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
279279
@@ -298,14 +298,14 @@ def setUp(self):
298298
299299 def test_search_in (self ):
300300 qs = Article .objects .annotate (score = SearchIn (path = "headline" , value = ["cross" , "river" ]))
301- self .assertCountEqual (qs . all , [self .article ])
301+ self .assertCountEqual (qs , [self .article ])
302302
303303 def test_constant_score (self ):
304304 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
305305 qs = Article .objects .annotate (
306306 score = SearchIn (path = "headline" , value = ["cross" , "river" ], score = constant_score )
307307 )
308- self .assertCountEqual (qs . all , [self .article ])
308+ self .assertCountEqual (qs , [self .article ])
309309 scored = qs .first ()
310310 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
311311
@@ -333,15 +333,15 @@ def setUp(self):
333333 Article .objects .create (headline = "cheetah" , number = 2 , body = "fastest animal" )
334334
335335 def test_search_phrase (self ):
336- qs = Article .objects .annotate (score = SearchPhrase (path = "body" , query = "quick brown" ))
337- self .assertCountEqual (qs . all , [self .article ])
336+ qs = Article .objects .annotate (score = SearchPhrase (path = "body" , query = "quick brown" , slop = 3 ))
337+ self .assertCountEqual (qs , [self .article ])
338338
339339 def test_constant_score (self ):
340340 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
341341 qs = Article .objects .annotate (
342342 score = SearchPhrase (path = "body" , query = "quick brown" , score = constant_score )
343343 )
344- self .assertCountEqual (qs . all , [self .article ])
344+ self .assertCountEqual (qs , [self .article ])
345345 scored = qs .first ()
346346 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
347347
@@ -432,14 +432,16 @@ def setUp(self):
432432
433433 def test_search_range (self ):
434434 qs = Article .objects .annotate (score = SearchRange (path = "number" , gte = 10 , lt = 30 ))
435- self .assertCountEqual (qs .all , [self .number20 ])
435+ self .assertCountEqual (qs , [self .number20 ])
436+ qs = Article .objects .annotate (score = SearchRange (path = "number" , gt = 20 , lte = 30 ))
437+ self .assertCountEqual (qs , [])
436438
437439 def test_constant_score (self ):
438440 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
439441 qs = Article .objects .annotate (
440442 score = SearchRange (path = "number" , gte = 10 , lt = 30 , score = constant_score )
441443 )
442- self .assertCountEqual (qs . all , [self .number20 ])
444+ self .assertCountEqual (qs , [self .number20 ])
443445 scored = qs .first ()
444446 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
445447
@@ -474,7 +476,7 @@ def test_search_regex(self):
474476 qs = Article .objects .annotate (
475477 score = SearchRegex (path = "headline" , query = "hello.*" , allow_analyzed_field = True )
476478 )
477- self .assertCountEqual (qs . all , [self .article ])
479+ self .assertCountEqual (qs , [self .article ])
478480
479481 def test_constant_score (self ):
480482 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
@@ -483,7 +485,7 @@ def test_constant_score(self):
483485 path = "headline" , query = "hello.*" , allow_analyzed_field = True , score = constant_score
484486 )
485487 )
486- self .assertCountEqual (qs . all , [self .article ])
488+ self .assertCountEqual (qs , [self .article ])
487489 scored = qs .first ()
488490 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
489491
@@ -514,19 +516,19 @@ def setUp(self):
514516
515517 def test_search_text (self ):
516518 qs = Article .objects .annotate (score = SearchText (path = "body" , query = "lazy" ))
517- self .assertCountEqual (qs . all , [self .article ])
519+ self .assertCountEqual (qs , [self .article ])
518520
519521 def test_search_lookup (self ):
520522 qs = Article .objects .filter (body__search = "lazy" )
521- self .assertCountEqual (qs . all , [self .article ])
523+ self .assertCountEqual (qs , [self .article ])
522524
523525 def test_search_text_with_fuzzy_and_criteria (self ):
524526 qs = Article .objects .annotate (
525527 score = SearchText (
526528 path = "body" , query = "lazzy" , fuzzy = {"maxEdits" : 2 }, match_criteria = "all"
527529 )
528530 )
529- self .assertCountEqual (qs . all , [self .article ])
531+ self .assertCountEqual (qs , [self .article ])
530532
531533 def test_constant_score (self ):
532534 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
@@ -539,7 +541,7 @@ def test_constant_score(self):
539541 score = constant_score ,
540542 )
541543 )
542- self .assertCountEqual (qs . all , [self .article ])
544+ self .assertCountEqual (qs , [self .article ])
543545 scored = qs .first ()
544546 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
545547
@@ -578,15 +580,17 @@ def setUp(self):
578580 Article .objects .create (headline = "batman" , number = 2 , body = "" )
579581
580582 def test_search_wildcard (self ):
581- qs = Article .objects .annotate (score = SearchWildcard (path = "headline" , query = "dark-*" ))
582- self .assertCountEqual (qs .all , [self .article ])
583+ qs = Article .objects .annotate (
584+ score = SearchWildcard (path = "headline" , query = "dark-*" , allow_analyzed_field = False )
585+ )
586+ self .assertCountEqual (qs , [self .article ])
583587
584588 def test_constant_score (self ):
585589 constant_score = SearchScoreOption ({"constant" : {"value" : 10 }})
586590 qs = Article .objects .annotate (
587591 score = SearchWildcard (path = "headline" , query = "dark-*" , score = constant_score )
588592 )
589- self .assertCountEqual (qs . all , [self .article ])
593+ self .assertCountEqual (qs , [self .article ])
590594 scored = qs .first ()
591595 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
592596
@@ -633,7 +637,7 @@ def test_search_geo_shape(self):
633637 qs = Article .objects .annotate (
634638 score = SearchGeoShape (path = "location" , relation = "within" , geometry = polygon )
635639 )
636- self .assertCountEqual (qs . all , [self .article ])
640+ self .assertCountEqual (qs , [self .article ])
637641
638642 def test_constant_score (self ):
639643 polygon = {
@@ -646,7 +650,7 @@ def test_constant_score(self):
646650 path = "location" , relation = "within" , geometry = polygon , score = constant_score
647651 )
648652 )
649- self .assertCountEqual (qs . all , [self .article ])
653+ self .assertCountEqual (qs , [self .article ])
650654 scored = qs .first ()
651655 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
652656
@@ -697,7 +701,7 @@ def test_search_geo_within(self):
697701 geometry = polygon ,
698702 )
699703 )
700- self .assertCountEqual (qs . all , [self .article ])
704+ self .assertCountEqual (qs , [self .article ])
701705
702706 def test_constant_score (self ):
703707 polygon = {
@@ -713,7 +717,7 @@ def test_constant_score(self):
713717 score = constant_score ,
714718 )
715719 )
716- self .assertCountEqual (qs . all , [self .article ])
720+ self .assertCountEqual (qs , [self .article ])
717721 scored = qs .first ()
718722 self .assertAlmostEqual (scored .score , 10.0 , places = 2 )
719723
@@ -775,7 +779,7 @@ def test_search_more_like_this(self):
775779 qs = Article .objects .annotate (score = SearchMoreLikeThis (documents = like_docs )).order_by (
776780 "score"
777781 )
778- self .assertQuerySetEqual (qs . all , [self .article1 , self .article2 ], lambda a : a .headline )
782+ self .assertQuerySetEqual (qs , [self .article1 , self .article2 ], lambda a : a .headline )
779783
780784
781785class CompoundSearchTests (SearchUtilsMixin ):
@@ -834,14 +838,14 @@ def test_expression(self):
834838 )
835839
836840 qs = Article .objects .annotate (score = compound ).order_by ("score" )
837- self .assertCountEqual (qs . all , [self .exoplanet ])
841+ self .assertCountEqual (qs , [self .exoplanet ])
838842
839843 def test_operations (self ):
840844 expr = SearchEquals (path = "headline" , value = "space exploration" ) & ~ SearchEquals (
841845 path = "number" , value = 3
842846 )
843847 qs = Article .objects .annotate (score = expr )
844- self .assertCountEqual (qs . all , [self .mars_mission , self .exoplanet ])
848+ self .assertCountEqual (qs , [self .mars_mission , self .exoplanet ])
845849
846850 def test_mixed_scores (self ):
847851 boost_score = SearchScoreOption ({"boost" : {"value" : 5 }})
@@ -853,11 +857,13 @@ def test_mixed_scores(self):
853857 must_expr = SearchEquals (path = "headline" , value = "space exploration" , score = boost_score )
854858 should_expr = SearchPhrase (path = "body" , query = "exoplanets" , score = constant_score )
855859 must_not_expr = SearchPhrase (path = "body" , query = "icy moons" , score = function_score )
860+ filter_ = SearchRange (path = "number" , gte = 1 , lt = 4 )
856861
857862 compound = CompoundExpression (
858863 must = [must_expr ],
859864 must_not = [must_not_expr ],
860865 should = [should_expr ],
866+ filter = [filter_ ],
861867 )
862868 qs = Article .objects .annotate (score = compound ).order_by ("-score" )
863869 self .assertListEqual (lambda : list (qs .all ()), [self .exoplanet , self .mars_mission ])
@@ -937,7 +943,7 @@ def test_multiple_vector_search(self):
937943
938944 def test_search_and_filter (self ):
939945 qs = Article .objects .filter (headline__search = "space exploration" , number__gt = 2 )
940- self .assertCountEqual (qs . all , [self .icy_moons ])
946+ self .assertCountEqual (qs , [self .icy_moons ])
941947
942948 def test_str_returns_expected_format (self ):
943949 must_expr = SearchEquals (path = "headline" , value = "space exploration" )
@@ -1003,7 +1009,7 @@ def test_vector_search(self):
10031009 limit = 2 ,
10041010 )
10051011 qs = Article .objects .annotate (score = expr ).order_by ("-score" )
1006- self .assertCountEqual (qs . all , [self .mars , self .cooking ])
1012+ self .assertCountEqual (qs , [self .mars , self .cooking ])
10071013
10081014 def test_str_returns_expected_format (self ):
10091015 vector_query = [0.1 , 0.2 , 0.3 ]
0 commit comments