def _create_search_index()

in python/src/tablestore_for_agent_memory/knowledge/knowledge_store.py [0:0]


    def _create_search_index(self):
        """Create search index if not exist."""
        self._search_index_schema = TablestoreHelper.add_schema(
            tablestore.FieldSchema("document_id", tablestore.FieldType.KEYWORD),
            self._search_index_schema
        )
        self._search_index_schema = TablestoreHelper.add_schema(
            tablestore.FieldSchema("tenant_id", tablestore.FieldType.KEYWORD),
            self._search_index_schema
        )
        self._search_index_schema = TablestoreHelper.add_schema(
            tablestore.FieldSchema(self._embedding_field,
                                   tablestore.FieldType.VECTOR,
                                   vector_options=tablestore.VectorOptions(
                                       data_type=tablestore.VectorDataType.VD_FLOAT_32,
                                       dimension=self._vector_dimension,
                                       metric_type=self._vector_metric_type,
                                   )),
            self._search_index_schema
        )
        self._search_index_schema = TablestoreHelper.add_schema(
            tablestore.FieldSchema(self._text_field, tablestore.FieldType.TEXT, analyzer=tablestore.AnalyzerType.MINWORD),
            self._search_index_schema
        )
        routing_fields = []
        if self._enable_multi_tenant:
            routing_fields = ['tenant_id']
        TablestoreHelper.create_search_index_if_not_exist(
            tablestore_client=self._client,
            table_name=self._table_name,
            index_name=self._search_index_name,
            index_schemas=self._search_index_schema,
            routing_fields=routing_fields,
        )