44
44
45
45
NOOFFSETS = "NOOFFSETS"
46
46
NOFIELDS = "NOFIELDS"
47
+ NOHL = "NOHL"
48
+ NOFREQS = "NOFREQS"
49
+ MAXTEXTFIELDS = "MAXTEXTFIELDS"
50
+ TEMPORARY = "TEMPORARY"
47
51
STOPWORDS = "STOPWORDS"
52
+ SKIPINITIALSCAN = "SKIPINITIALSCAN"
48
53
WITHSCORES = "WITHSCORES"
49
54
FUZZY = "FUZZY"
50
55
WITHPAYLOADS = "WITHPAYLOADS"
@@ -66,27 +71,57 @@ def create_index(
66
71
no_field_flags = False ,
67
72
stopwords = None ,
68
73
definition = None ,
74
+ max_text_fields = False ,
75
+ temporary = None ,
76
+ no_highlight = False ,
77
+ no_term_frequencies = False ,
78
+ skip_initial_scan = False ,
69
79
):
70
80
"""
71
81
Create the search index. The index must not already exist.
72
82
73
83
### Parameters:
74
84
75
85
- **fields**: a list of TextField or NumericField objects
76
- - **no_term_offsets**: If true, we will not save term offsets in the index
77
- - **no_field_flags**: If true, we will not save field flags that allow searching in specific fields
78
- - **stopwords**: If not None, we create the index with this custom stopword list. The list can be empty
86
+ - **no_term_offsets**: If true, we will not save term offsets in
87
+ the index
88
+ - **no_field_flags**: If true, we will not save field flags that
89
+ allow searching in specific fields
90
+ - **stopwords**: If not None, we create the index with this custom
91
+ stopword list. The list can be empty
92
+ - **max_text_fields**: If true, we will encode indexes as if there
93
+ were more than 32 text fields which allows you to add additional
94
+ fields (beyond 32).
95
+ - **temporary**: Create a lightweight temporary index which will
96
+ expire after the specified period of inactivity (in seconds). The
97
+ internal idle timer is reset whenever the index is searched or added to.
98
+ - **no_highlight**: If true, disabling highlighting support.
99
+ Also implied by no_term_offsets.
100
+ - **no_term_frequencies**: If true, we avoid saving the term frequencies
101
+ in the index.
102
+ - **skip_initial_scan**: If true, we do not scan and index.
79
103
80
104
For more information: https://oss.redis.com/redisearch/Commands/#ftcreate
81
105
""" # noqa
82
106
83
107
args = [CREATE_CMD , self .index_name ]
84
108
if definition is not None :
85
109
args += definition .args
110
+ if max_text_fields :
111
+ args .append (MAXTEXTFIELDS )
112
+ if temporary is not None and isinstance (temporary , int ):
113
+ args .append (TEMPORARY )
114
+ args .append (temporary )
86
115
if no_term_offsets :
87
116
args .append (NOOFFSETS )
117
+ if no_highlight :
118
+ args .append (NOHL )
88
119
if no_field_flags :
89
120
args .append (NOFIELDS )
121
+ if no_term_frequencies :
122
+ args .append (NOFREQS )
123
+ if skip_initial_scan :
124
+ args .append (SKIPINITIALSCAN )
90
125
if stopwords is not None and isinstance (stopwords , (list , tuple , set )):
91
126
args += [STOPWORDS , len (stopwords )]
92
127
if len (stopwords ) > 0 :
@@ -129,7 +164,6 @@ def dropindex(self, delete_documents=False):
129
164
### Parameters:
130
165
131
166
- **delete_documents**: If `True`, all documents will be deleted.
132
-
133
167
For more information: https://oss.redis.com/redisearch/Commands/#ftdropindex
134
168
""" # noqa
135
169
keep_str = "" if delete_documents else "KEEPDOCS"
@@ -217,23 +251,27 @@ def add_document(
217
251
### Parameters
218
252
219
253
- **doc_id**: the id of the saved document.
220
- - **nosave**: if set to true, we just index the document, and don't \
221
- save a copy of it. This means that searches will just return ids.
222
- - **score**: the document ranking, between 0.0 and 1.0.
223
- - **payload**: optional inner-index payload we can save for fast access in scoring functions
224
- - **replace**: if True, and the document already is in the index, \
254
+ - **nosave**: if set to true, we just index the document, and don't
255
+ save a copy of it. This means that searches will just
256
+ return ids.
257
+ - **score**: the document ranking, between 0.0 and 1.0
258
+ - **payload**: optional inner-index payload we can save for fast
259
+ i access in scoring functions
260
+ - **replace**: if True, and the document already is in the index,
225
261
we perform an update and reindex the document
226
- - **partial**: if True, the fields specified will be added to the \
227
- existing document. \
228
- This has the added benefit that any fields specified \
229
- with `no_index` will not be reindexed again. Implies `replace`
262
+ - **partial**: if True, the fields specified will be added to the
263
+ existing document.
264
+ This has the added benefit that any fields specified
265
+ with `no_index`
266
+ will not be reindexed again. Implies `replace`
230
267
- **language**: Specify the language used for document tokenization.
231
- - **no_create**: if True, the document is only updated and reindexed \
232
- if it already exists. If the document does not exist, an error will be \
233
- returned. Implies `replace`
234
- - **fields** kwargs dictionary of the document fields to be saved and/or indexed.
235
-
236
- NOTE: Geo points shoule be encoded as strings of "lon,lat"
268
+ - **no_create**: if True, the document is only updated and reindexed
269
+ if it already exists.
270
+ If the document does not exist, an error will be
271
+ returned. Implies `replace`
272
+ - **fields** kwargs dictionary of the document fields to be saved
273
+ and/or indexed.
274
+ NOTE: Geo points shoule be encoded as strings of "lon,lat"
237
275
238
276
For more information: https://oss.redis.com/redisearch/Commands/#ftadd
239
277
""" # noqa
@@ -481,7 +519,7 @@ def spellcheck(self, query, distance=None, include=None, exclude=None):
481
519
482
520
**query**: search query.
483
521
**distance***: the maximal Levenshtein distance for spelling
484
- suggestions (default: 1, max: 4).
522
+ suggestions (default: 1, max: 4).
485
523
**include**: specifies an inclusion custom dictionary.
486
524
**exclude**: specifies an exclusion custom dictionary.
487
525
0 commit comments