联 系 我 们
售前咨询
售后咨询
微信关注:星环科技服务号
更多联系方式 >
8.8 Index Operations
更新时间:12/16/2024, 10:45:04 AM

Create Vector Index

index_created = table.create_index(field_name = "vector", index_name = "vector_index", index_type = IndexType.IVF_FLAT, metric_type = MetricType.L2, nlist=10, )
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when creating vector index, “ValueError” exception will be raised.

Parameter description:

Table 110. Create Vector Index (Python API)
Parameters Description Required

field_name (str)

Name of field to index

Yes

index_name (str)

Index name

Yes

index_type (IndexType)

Index type, must be one of types stored in IndexType(Enum) class

Yes

metric_type (MetricType)

Metric type, must be one of types stored in MetricType(Enum) class

Yes

**kwargs

Other alternative parameters, depends on index and metric type

No

Activate Vector Index

index_activated = table.activate_index("index_name")
复制

Result:

This method returns a String representing the status of activation operation. If the error pops up when activating index, “ValueError” exception will be raised.

Parameter description:

Table 111. Activate Vector Index (Python API)
Parameters Description Required

index_name (str)

Index to be activated

Yes

wait_for_completion (bool)

Whether to wait until this job is done

No, defaults to True

timeout (str)

Operation timeout, in seconds

No, defaults to "120"

Release Vector Index

index_released = table.release_index("index_name")
复制

Result:

This method returns a String representing the status of activation operation. If the error pops up when activating index, “ValueError” exception will be raised.

Parameter description:

Table 112. Release Vector Index (Python API)
Parameters Description Required

index_name (str)

Index to be activated

Yes

wait_for_completion (bool)

Whether to wait until this job is done

No, defaults to True

timeout (str)

Operation timeout, in seconds

No, defaults to "120"

Load Vector Index

index_loaded = table.load_index("index_name")
复制

Result:

This method returns a String representing the status of load operation. If the error pops up when loading index, “ValueError” exception will be raised.

Parameter description:

Table 113. Load Vector Index (Python API)
Parameters Description Required

index_name (str)

Index to be loaded

Yes

wait_for_completion (bool)

Whether to wait until this job is done

No, defaults to True

timeout (str)

Operation timeout, in seconds

No, defaults to "120"

Check Vector Index

index = table.get_index()
复制

Result:

This method returns a Dictionary containing all indexes of current table.

Delete Vector Index

index_dropped = table.drop_index("index_name")
复制

Result:

This method returns True if it succeeds. Otherwise, “ValueError” exception will be raised.

Parameter description:

Table 114. Delete Vector Index (Python API)
Parameters Description Required

index_name (str)

Index to be deleted

Yes

Create Scalar Index

scalar_index_created = table.create_scalar_index(field_names = ["text"], index_name = "text1_index")
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when creating scalar index, “ValueError” exception will be raised.

Parameter description:

Table 115. Create Scalar Index (Python API)
Parameters Description Required

field_names (list[str])

Field list to index

Yes

index_name (str)

Index to be created

Yes

Delete Scalar Index

scalar_index_deleted = table.delete_scalar_index(index_name = "text1_index")
复制

Result:

This method returns a Boolean value to represent whether this operation is successful. If the error pops up when deleting scalar index, “ValueError” exception will be raised.

Parameter description:

Table 116. Delete Scalar Index (Python API)
Parameters Description Required

field_names (list[str])

Field list to delete index

Yes

index_name (str)

Index to be deleted

Yes