@@ -568,6 +568,35 @@ def testDictOps(self):
568568 # Remove rest of the items before reload
569569 client .dict_del ('custom_dict' , * res )
570570
571+ def testPhoneticMatcher (self ):
572+ conn = self .redis ()
573+
574+ with conn as r :
575+ # Creating a client with a given index name
576+ client = Client ('myIndex' , port = conn .port )
577+ client .redis .flushdb ()
578+
579+ client .create_index ((TextField ('name' ),))
580+
581+ client .add_document ('doc1' , name = 'Jon' )
582+ client .add_document ('doc2' , name = 'John' )
583+
584+ res = client .search (Query ("Jon" ))
585+ self .assertEqual (1 , len (res .docs ))
586+ self .assertEqual ('Jon' , res .docs [0 ].name )
587+
588+ # Drop and create index with phonetic matcher
589+ client .redis .flushdb ()
590+
591+ client .create_index ((TextField ('name' , phonetic_matcher = 'dm:en' ),))
592+
593+ client .add_document ('doc1' , name = 'Jon' )
594+ client .add_document ('doc2' , name = 'John' )
595+
596+ res = client .search (Query ("Jon" ))
597+ self .assertEqual (2 , len (res .docs ))
598+ self .assertEqual (['John' , 'Jon' ], sorted ([d .name for d in res .docs ]))
599+
571600 def testGet (self ):
572601 client = self .getCleanClient ('idx' )
573602 client .create_index ((TextField ('f1' ), TextField ('f2' )))
0 commit comments