@@ -23,8 +23,6 @@ class RedisSearchTestCase(ModuleTestCase('../module.so')):
23
23
def createIndex (self , client , num_docs = 100 ):
24
24
25
25
assert isinstance (client , Client )
26
- #conn.flushdb()
27
- #client = Client('test', port=conn.port)
28
26
try :
29
27
client .create_index ((TextField ('play' , weight = 5.0 ),
30
28
TextField ('txt' ),
@@ -172,36 +170,9 @@ def getCleanClient(self, name):
172
170
except :
173
171
pass
174
172
173
+ client .redis .flushdb ()
175
174
return client
176
175
177
- def testAddHash (self ):
178
- conn = self .redis ()
179
-
180
- with conn as r :
181
- # Creating a client with a given index name
182
- client = Client ('idx' , port = conn .port )
183
-
184
- client .redis .flushdb ()
185
- # Creating the index definition and schema
186
- client .create_index ((TextField ('title' ,
187
- weight = 5.0 ), TextField ('body' )))
188
-
189
- client .redis .hset (
190
- 'doc1' ,
191
- mapping = {
192
- 'title' : 'RediSearch' ,
193
- 'body' : 'Redisearch impements a search engine on top of redis'
194
- })
195
- # Indexing the hash
196
- client .add_document_hash ('doc1' )
197
-
198
- # Searching with complext parameters:
199
- q = Query ("search engine" ).verbatim ().no_content ().paging (0 , 5 )
200
-
201
- res = client .search (q )
202
-
203
- self .assertEqual ('doc1' , res .docs [0 ].id )
204
-
205
176
def testPayloads (self ):
206
177
207
178
conn = self .redis ()
@@ -276,24 +247,19 @@ def testReplace(self):
276
247
277
248
278
249
def testStopwords (self ):
279
- conn = self .redis ()
280
250
281
- with conn as r :
282
- # Creating a client with a given index name
283
- client = Client ('idx' , port = conn .port )
284
- try :
285
- client .drop_index ()
286
- except :
287
- pass
288
- client .create_index ((TextField ('txt' ),), stopwords = ['foo' , 'bar' , 'baz' ])
289
- client .add_document ('doc1' , txt = 'foo bar' )
290
- client .add_document ('doc2' , txt = 'hello world' )
291
-
292
- q1 = Query ("foo bar" ).no_content ()
293
- q2 = Query ("foo bar hello world" ).no_content ()
294
- res1 , res2 = client .search (q1 ), client .search (q2 )
295
- self .assertEqual (0 , res1 .total )
296
- self .assertEqual (1 , res2 .total )
251
+ # Creating a client with a given index name
252
+ client = self .getCleanClient ('idx' )
253
+
254
+ client .create_index ((TextField ('txt' ),), stopwords = ['foo' , 'bar' , 'baz' ])
255
+ client .add_document ('doc1' , txt = 'foo bar' )
256
+ client .add_document ('doc2' , txt = 'hello world' )
257
+
258
+ q1 = Query ("foo bar" ).no_content ()
259
+ q2 = Query ("foo bar hello world" ).no_content ()
260
+ res1 , res2 = client .search (q1 ), client .search (q2 )
261
+ self .assertEqual (0 , res1 .total )
262
+ self .assertEqual (1 , res2 .total )
297
263
298
264
def testFilters (self ):
299
265
@@ -458,11 +424,9 @@ def testAutoComplete(self):
458
424
self .assertTrue (sug .payload .startswith ('pl' ))
459
425
460
426
def testNoIndex (self ):
461
- client = Client ('idx' , port = self .server .port )
462
- try :
463
- client .drop_index ()
464
- except :
465
- pass
427
+
428
+ # Creating a client with a given index name
429
+ client = self .getCleanClient ('idx' )
466
430
467
431
client .create_index (
468
432
(TextField ('f1' , no_index = True , sortable = True ), TextField ('f2' )))
0 commit comments