@@ -107,7 +107,7 @@ def client(modclient):
107
107
def test_client (client ):
108
108
num_docs = 500
109
109
createIndex (client .ft (), num_docs = num_docs )
110
- waitForIndex (client , " idx" )
110
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
111
111
# verify info
112
112
info = client .ft ().info ()
113
113
for k in [
@@ -252,7 +252,7 @@ def test_replace(client):
252
252
253
253
client .ft ().add_document ("doc1" , txt = "foo bar" )
254
254
client .ft ().add_document ("doc2" , txt = "foo bar" )
255
- waitForIndex (client , " idx" )
255
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
256
256
257
257
res = client .ft ().search ("foo bar" )
258
258
assert 2 == res .total
@@ -272,7 +272,7 @@ def test_stopwords(client):
272
272
client .ft ().create_index ((TextField ("txt" ),), stopwords = ["foo" , "bar" , "baz" ])
273
273
client .ft ().add_document ("doc1" , txt = "foo bar" )
274
274
client .ft ().add_document ("doc2" , txt = "hello world" )
275
- waitForIndex (client , " idx" )
275
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
276
276
277
277
q1 = Query ("foo bar" ).no_content ()
278
278
q2 = Query ("foo bar hello world" ).no_content ()
@@ -287,7 +287,7 @@ def test_filters(client):
287
287
client .ft ().add_document ("doc1" , txt = "foo bar" , num = 3.141 , loc = "-0.441,51.458" )
288
288
client .ft ().add_document ("doc2" , txt = "foo baz" , num = 2 , loc = "-0.1,51.2" )
289
289
290
- waitForIndex (client , " idx" )
290
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
291
291
# Test numerical filter
292
292
q1 = Query ("foo" ).add_filter (NumericFilter ("num" , 0 , 2 )).no_content ()
293
293
q2 = (
@@ -456,7 +456,7 @@ def test_no_index(client):
456
456
client .ft ().add_document (
457
457
"doc2" , field = "aab" , text = "2" , numeric = "2" , geo = "2,2" , tag = "2"
458
458
)
459
- waitForIndex (client , " idx" )
459
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
460
460
461
461
res = client .ft ().search (Query ("@text:aa*" ))
462
462
assert 0 == res .total
@@ -498,7 +498,7 @@ def test_partial(client):
498
498
client .ft ().add_document ("doc2" , f1 = "f1_val" , f2 = "f2_val" )
499
499
client .ft ().add_document ("doc1" , f3 = "f3_val" , partial = True )
500
500
client .ft ().add_document ("doc2" , f3 = "f3_val" , replace = True )
501
- waitForIndex (client , " idx" )
501
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
502
502
503
503
# Search for f3 value. All documents should have it
504
504
res = client .ft ().search ("@f3:f3_val" )
@@ -516,7 +516,7 @@ def test_no_create(client):
516
516
client .ft ().add_document ("doc2" , f1 = "f1_val" , f2 = "f2_val" )
517
517
client .ft ().add_document ("doc1" , f3 = "f3_val" , no_create = True )
518
518
client .ft ().add_document ("doc2" , f3 = "f3_val" , no_create = True , partial = True )
519
- waitForIndex (client , " idx" )
519
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
520
520
521
521
# Search for f3 value. All documents should have it
522
522
res = client .ft ().search ("@f3:f3_val" )
@@ -546,7 +546,7 @@ def test_explaincli(client):
546
546
@pytest .mark .redismod
547
547
def test_summarize (client ):
548
548
createIndex (client .ft ())
549
- waitForIndex (client , " idx" )
549
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
550
550
551
551
q = Query ("king henry" ).paging (0 , 1 )
552
552
q .highlight (fields = ("play" , "txt" ), tags = ("<b>" , "</b>" ))
@@ -654,7 +654,7 @@ def test_tags(client):
654
654
655
655
client .ft ().add_document ("doc1" , txt = "fooz barz" , tags = tags )
656
656
client .ft ().add_document ("doc2" , txt = "noodles" , tags = tags2 )
657
- waitForIndex (client , " idx" )
657
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
658
658
659
659
q = Query ("@tags:{foo}" )
660
660
res = client .ft ().search (q )
@@ -714,7 +714,7 @@ def test_spell_check(client):
714
714
715
715
client .ft ().add_document ("doc1" , f1 = "some valid content" , f2 = "this is sample text" )
716
716
client .ft ().add_document ("doc2" , f1 = "very important" , f2 = "lorem ipsum" )
717
- waitForIndex (client , " idx" )
717
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
718
718
719
719
# test spellcheck
720
720
res = client .ft ().spellcheck ("impornant" )
@@ -1304,6 +1304,31 @@ def test_fields_as_name(client):
1304
1304
assert "25" == total [0 ].just_a_number
1305
1305
1306
1306
1307
+ @pytest .mark .redismod
1308
+ def test_casesensitive (client ):
1309
+ # create index
1310
+ SCHEMA = (TagField ("t" , case_sensitive = False ),)
1311
+ client .ft ().create_index (SCHEMA )
1312
+ client .ft ().client .hset ("1" , "t" , "HELLO" )
1313
+ client .ft ().client .hset ("2" , "t" , "hello" )
1314
+
1315
+ res = client .ft ().search ("@t:{HELLO}" ).docs
1316
+
1317
+ assert 2 == len (res )
1318
+ assert "1" == res [0 ].id
1319
+ assert "2" == res [1 ].id
1320
+
1321
+ # create casesensitive index
1322
+ client .ft ().dropindex ()
1323
+ SCHEMA = (TagField ("t" , case_sensitive = True ),)
1324
+ client .ft ().create_index (SCHEMA )
1325
+ waitForIndex (client , getattr (client .ft (), "index_name" , "idx" ))
1326
+
1327
+ res = client .ft ().search ("@t:{HELLO}" ).docs
1328
+ assert 1 == len (res )
1329
+ assert "1" == res [0 ].id
1330
+
1331
+
1307
1332
@pytest .mark .redismod
1308
1333
@skip_ifmodversion_lt ("2.2.0" , "search" )
1309
1334
def test_search_return_fields (client ):
@@ -1321,7 +1346,7 @@ def test_search_return_fields(client):
1321
1346
NumericField ("$.flt" ),
1322
1347
)
1323
1348
client .ft ().create_index (SCHEMA , definition = definition )
1324
- waitForIndex (client , " idx" )
1349
+ waitForIndex (client , getattr ( client . ft (), "index_name" , " idx") )
1325
1350
1326
1351
total = client .ft ().search (Query ("*" ).return_field ("$.t" , as_field = "txt" )).docs
1327
1352
assert 1 == len (total )
0 commit comments