MCPcopy Create free account
hub / github.com/alibaba/zvec / create_index

Method create_index

python/zvec/model/collection.py:107–136  ·  view source on GitHub ↗

Create an index on a field. Vector index types (HNSW, IVF, FLAT) can only be applied to vector fields. Inverted index (`InvertIndexParam`) is for scalar fields. FTS index (`FtsIndexParam`) is for full-text search on STRING fields. Args: field_name (str):

(
        self,
        field_name: str,
        index_param: Union[
            HnswIndexParam,
            HnswRabitqIndexParam,
            IVFIndexParam,
            FlatIndexParam,
            InvertIndexParam,
            FtsIndexParam,
        ],
        option: IndexOption = IndexOption(),
    )

Source from the content-addressed store, hash-verified

105
106 # ========== Index DDL Methods ==========
107 def create_index(
108 self,
109 field_name: str,
110 index_param: Union[
111 HnswIndexParam,
112 HnswRabitqIndexParam,
113 IVFIndexParam,
114 FlatIndexParam,
115 InvertIndexParam,
116 FtsIndexParam,
117 ],
118 option: IndexOption = IndexOption(),
119 ) -> None:
120 """Create an index on a field.
121
122 Vector index types (HNSW, IVF, FLAT) can only be applied to vector fields.
123 Inverted index (`InvertIndexParam`) is for scalar fields.
124 FTS index (`FtsIndexParam`) is for full-text search on STRING fields.
125
126 Args:
127 field_name (str): Name of the field to index.
128 index_param (Union[HnswIndexParam, HnswRabitqIndexParam, IVFIndexParam, FlatIndexParam, InvertIndexParam, FtsIndexParam]):
129 Index configuration.
130 option (Optional[IndexOption], optional): Index creation options.
131 Defaults to ``IndexOption()``.
132
133 """
134 self._obj.CreateIndex(field_name, index_param, option)
135 self._schema = CollectionSchema._from_core(self._obj.Schema())
136 self._querier._schema = self._schema
137
138 def drop_index(self, field_name: str) -> None:
139 """Remove the index from a field.

Calls 3

CreateIndexMethod · 0.80
SchemaMethod · 0.80
_from_coreMethod · 0.45