Skip to content

Commit 5c9456b

Browse files
cheeseandcerealgkorland
authored andcommitted
fix textfield bug (#44)
Signed-off-by: Adam Crowder <adam@adamcrowder.net>
1 parent 051fcdc commit 5c9456b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

redisearch/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class TextField(Field):
3939
def __init__(self, name, weight=1.0, sortable=False, no_stem=False,
4040
no_index=False):
4141
args = [Field.TEXT, Field.WEIGHT, weight]
42-
if sortable:
43-
args.append(Field.SORTABLE)
4442
if no_stem:
4543
args.append(self.NOSTEM)
44+
if sortable:
45+
args.append(Field.SORTABLE)
4646
if no_index:
4747
args.append(self.NOINDEX)
4848

test/test.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,22 @@ def testTags(self):
494494
res = client.search(q)
495495
self.assertEqual(1, res.total)
496496

497+
def testTextFieldSortableNostem(self):
498+
conn = self.redis()
499+
500+
with conn as r:
501+
# Creating a client with a given index name
502+
client = Client('sortableNostem', port=conn.port)
503+
client.redis.flushdb()
504+
505+
# Creating the index definition with sortable and no_stem
506+
client.create_index((TextField('txt', sortable=True, no_stem=True),))
507+
508+
# Now get the index info to confirm its contents
509+
response = client.info()
510+
self.assertIn(b'SORTABLE', response['fields'][0])
511+
self.assertIn(b'NOSTEM', response['fields'][0])
512+
497513
def testAlterSchemaAdd(self):
498514
conn = self.redis()
499515

@@ -518,7 +534,6 @@ def testAlterSchemaAdd(self):
518534
res = client.search(q)
519535
self.assertEqual(1, res.total)
520536

521-
522537
if __name__ == '__main__':
523538

524539
unittest.main()

0 commit comments

Comments
 (0)