MCPcopy
hub / github.com/redis/redis-py / create_index

Method create_index

redis/commands/search/commands.py:903–971  ·  view source on GitHub ↗

Creates the search index. The index must not already exist. For more information, see https://redis.io/commands/ft.create/ Args: fields: A list of Field objects. no_term_offsets: If `true`, term offsets will not be saved in the index. no

(
        self,
        fields: List[Field],
        no_term_offsets: bool = False,
        no_field_flags: bool = False,
        stopwords: Optional[List[str]] = None,
        definition: Optional[IndexDefinition] = None,
        max_text_fields=False,
        temporary=None,
        no_highlight: bool = False,
        no_term_frequencies: bool = False,
        skip_initial_scan: bool = False,
    )

Source from the content-addressed store, hash-verified

901 return self.BatchIndexer(self, chunk_size=chunk_size)
902
903 def create_index(
904 self,
905 fields: List[Field],
906 no_term_offsets: bool = False,
907 no_field_flags: bool = False,
908 stopwords: Optional[List[str]] = None,
909 definition: Optional[IndexDefinition] = None,
910 max_text_fields=False,
911 temporary=None,
912 no_highlight: bool = False,
913 no_term_frequencies: bool = False,
914 skip_initial_scan: bool = False,
915 ):
916 """
917 Creates the search index. The index must not already exist.
918
919 For more information, see https://redis.io/commands/ft.create/
920
921 Args:
922 fields: A list of Field objects.
923 no_term_offsets: If `true`, term offsets will not be saved in the index.
924 no_field_flags: If true, field flags that allow searching in specific fields
925 will not be saved.
926 stopwords: If provided, the index will be created with this custom stopword
927 list. The list can be empty.
928 definition: If provided, the index will be created with this custom index
929 definition.
930 max_text_fields: If true, indexes will be encoded as if there were more than
931 32 text fields, allowing for additional fields beyond 32.
932 temporary: Creates a lightweight temporary index which will expire after the
933 specified period of inactivity. The internal idle timer is reset
934 whenever the index is searched or added to.
935 no_highlight: If true, disables highlighting support. Also implied by
936 `no_term_offsets`.
937 no_term_frequencies: If true, term frequencies will not be saved in the
938 index.
939 skip_initial_scan: If true, the initial scan and indexing will be skipped.
940
941 """
942 args = [CREATE_CMD, self.index_name]
943 if definition is not None:
944 args += definition.args
945 if max_text_fields:
946 args.append(MAXTEXTFIELDS)
947 if temporary is not None and isinstance(temporary, int):
948 args.append(TEMPORARY)
949 args.append(temporary)
950 if no_term_offsets:
951 args.append(NOOFFSETS)
952 if no_highlight:
953 args.append(NOHL)
954 if no_field_flags:
955 args.append(NOFIELDS)
956 if no_term_frequencies:
957 args.append(NOFREQS)
958 if skip_initial_scan:
959 args.append(SKIPINITIALSCAN)
960 if stopwords is not None and isinstance(stopwords, (list, tuple, set)):

Callers 15

search_vss.pyFile · 0.80
query_geo.pyFile · 0.80
home_json.pyFile · 0.80
query_agg.pyFile · 0.80
query_em.pyFile · 0.80
query_ft.pyFile · 0.80
geo_index.pyFile · 0.80
query_range.pyFile · 0.80
query_combined.pyFile · 0.80

Calls 3

redis_argsMethod · 0.80
appendMethod · 0.45
execute_commandMethod · 0.45

Tested by 15

createIndexMethod · 0.64
test_scoresMethod · 0.64
test_stopwordsMethod · 0.64
test_filtersMethod · 0.64
test_sort_byMethod · 0.64
test_drop_indexMethod · 0.64
test_exampleMethod · 0.64
test_no_indexMethod · 0.64
test_explainMethod · 0.64