@@ -84,13 +84,12 @@ class TagField(Field):
84
84
See http://redisearch.io/Tags/
85
85
"""
86
86
def __init__ (self , name , separator = ',' , no_index = False ):
87
- Field .__init__ (self , name , Field .TAG )
88
- if separator != ',' :
89
- self .args .append (Field .SEPARATOR )
90
- self .args .append (separator )
87
+ args = [Field .TAG , Field .SEPARATOR , separator ]
91
88
92
89
if no_index :
93
- self .args .append (Field .NOINDEX )
90
+ args .append (Field .NOINDEX )
91
+
92
+ Field .__init__ (self , name , * args )
94
93
95
94
96
95
class Client (object ):
@@ -102,6 +101,7 @@ class Client(object):
102
101
NUMERIC = 'NUMERIC'
103
102
104
103
CREATE_CMD = 'FT.CREATE'
104
+ ALTER_CMD = 'FT.ALTER'
105
105
SEARCH_CMD = 'FT.SEARCH'
106
106
ADD_CMD = 'FT.ADD'
107
107
DROP_CMD = 'FT.DROP'
@@ -200,6 +200,21 @@ def create_index(self, fields, no_term_offsets=False,
200
200
201
201
return self .redis .execute_command (* args )
202
202
203
+ def alter_schema_add (self , fields ):
204
+ """
205
+ Alter the existing search index by adding new fields. The index must already exist.
206
+
207
+ ### Parameters:
208
+
209
+ - **fields**: a list of Field objects to add for the index
210
+ """
211
+
212
+ args = [self .ALTER_CMD , self .index_name , 'SCHEMA' , 'ADD' ]
213
+
214
+ args += list (itertools .chain (* (f .redis_args () for f in fields )))
215
+
216
+ return self .redis .execute_command (* args )
217
+
203
218
def drop_index (self ):
204
219
"""
205
220
Drop the index if it exists
@@ -367,4 +382,4 @@ def aggregate(self, query):
367
382
rows = raw [1 :]
368
383
369
384
res = AggregateResult (rows , cursor , schema )
370
- return res
385
+ return res
0 commit comments