diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py index 7305e1b76b8..90151f60cf0 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py @@ -45,6 +45,9 @@ SQL_VECTOR_EMBEDDING_POLICY_EXAMPLE = """--vector-embeddings "{\\"vectorEmbeddings\\": [{\\"path\\": \\"/vector1\\", \\"dataType\\": \\"float32\\", \\"dimensions\\": 2, \\"distanceFunction\\": \\"dotproduct\\" }]}" """ +SQL_FULL_TEXT_SEARCH_POLICY_EXAMPLE = """--full-text-policy "{\\"fullTextPaths\\": [{\\"path\\": \\"/ftPath1\\", \\"language\\": \\"en-US\\" }]}" +""" + SQL_UNIQUE_KEY_POLICY_EXAMPLE = """--unique-key-policy "{\\"uniqueKeys\\": [{\\"paths\\": [\\"/path/to/key1\\"]}, {\\"paths\\": [\\"/path/to/key2\\"]}]}" """ @@ -167,6 +170,7 @@ def load_arguments(self, _): c.argument('partition_key_path', help='Partition Key Path, e.g., \'/properties/name\'') c.argument('client_encryption_policy', options_list=['--cep'], type=shell_safe_json_parse, completer=FilesCompleter(), validator=validate_client_encryption_policy, help='Client Encryption Policy, you can enter it as a string or as a file, e.g., --cep @policy-file.json or ' + SQL_CLIENT_ENCRYPTION_POLICY_EXAMPLE) c.argument('vector_embedding_policy', options_list=['--vector-embeddings'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Vector Embedding Policy, you can enter it as a string or as a file, e.g., --vector-embeddings @policy-file.json or ' + SQL_VECTOR_EMBEDDING_POLICY_EXAMPLE) + c.argument('full_text_policy', options_list=['--full-text-policy'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Full Text Policy, you can enter it as a string or as a file, e.g., --full-text-policy @policy-file.json or ' + SQL_FULL_TEXT_POLICY_EXAMPLE) c.argument('indexing_policy', type=shell_safe_json_parse, completer=FilesCompleter(), help='Indexing Policy, you can enter it as a string or as a file, e.g., --indexing-policy @policy-file.json)') c.argument('default_ttl', type=int, help='Default TTL. Provide 0 to disable.') @@ -222,6 +226,7 @@ def load_arguments(self, _): c.argument('indexing_policy', options_list=['--idx'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Indexing Policy, you can enter it as a string or as a file, e.g., --idx @policy-file.json or ' + SQL_INDEXING_POLICY_EXAMPLE) c.argument('client_encryption_policy', options_list=['--cep'], type=shell_safe_json_parse, completer=FilesCompleter(), validator=validate_client_encryption_policy, help='Client Encryption Policy, you can enter it as a string or as a file, e.g., --cep @policy-file.json or ' + SQL_CLIENT_ENCRYPTION_POLICY_EXAMPLE) c.argument('vector_embedding_policy', options_list=['--vector-embeddings'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Vector Embedding Policy, you can enter it as a string or as a file, e.g., --vector-embeddings @policy-file.json or ' + SQL_VECTOR_EMBEDDING_POLICY_EXAMPLE) + c.argument('full_text_policy', options_list=['--full-text-policy'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Full Text Policy, you can enter it as a string or as a file, e.g., --full-text-policy @policy-file.json or ' + SQL_FULL_TEXT_POLICY_EXAMPLE) c.argument('unique_key_policy', options_list=['--unique-key-policy', '-u'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Unique Key Policy, you can enter it as a string or as a file, e.g., --unique-key-policy @policy-file.json or ' + SQL_UNIQUE_KEY_POLICY_EXAMPLE) c.argument('conflict_resolution_policy', options_list=['--conflict-resolution-policy', '-c'], type=shell_safe_json_parse, completer=FilesCompleter(), help='Conflict Resolution Policy, you can enter it as a string or as a file, e.g., --conflict-resolution-policy @policy-file.json or ' + SQL_GREMLIN_CONFLICT_RESOLUTION_POLICY_EXAMPLE) c.argument('max_throughput', max_throughput_type) diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py index 1f25f5a6f87..2cd74d01169 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py @@ -607,9 +607,10 @@ def _populate_sql_container_definition(sql_container_resource, partition_key_version, conflict_resolution_policy, analytical_storage_ttl, - vector_embedding_policy): + vector_embedding_policy, + full_text_policy): if all(arg is None for arg in - [partition_key_path, partition_key_version, default_ttl, indexing_policy, unique_key_policy, client_encryption_policy, conflict_resolution_policy, analytical_storage_ttl, vector_embedding_policy]): + [partition_key_path, partition_key_version, default_ttl, indexing_policy, unique_key_policy, client_encryption_policy, conflict_resolution_policy, analytical_storage_ttl, vector_embedding_policy, full_text_policy]): return False if partition_key_path is not None: @@ -641,6 +642,9 @@ def _populate_sql_container_definition(sql_container_resource, if vector_embedding_policy is not None: sql_container_resource.vector_embedding_policy = vector_embedding_policy + if full_text_policy is not None: + sql_container_resource.full_text_policy = full_text_policy + return True @@ -659,7 +663,8 @@ def cli_cosmosdb_sql_container_create(client, unique_key_policy=None, conflict_resolution_policy=None, analytical_storage_ttl=None, - vector_embedding_policy=None): + vector_embedding_policy=None, + full_text_policy=None): """Creates an Azure Cosmos DB SQL container """ sql_container_resource = SqlContainerResource(id=container_name) @@ -672,7 +677,8 @@ def cli_cosmosdb_sql_container_create(client, partition_key_version, conflict_resolution_policy, analytical_storage_ttl, - vector_embedding_policy) + vector_embedding_policy, + full_text_policy) options = _get_options(throughput, max_throughput) @@ -695,7 +701,8 @@ def cli_cosmosdb_sql_container_update(client, default_ttl=None, indexing_policy=None, analytical_storage_ttl=None, - vector_embedding_policy=None): + vector_embedding_policy=None, + full_text_policy=None): """Updates an Azure Cosmos DB SQL container """ logger.debug('reading SQL container') sql_container = client.get_sql_container(resource_group_name, account_name, database_name, container_name) @@ -707,6 +714,7 @@ def cli_cosmosdb_sql_container_update(client, sql_container_resource.unique_key_policy = sql_container.resource.unique_key_policy sql_container_resource.conflict_resolution_policy = sql_container.resource.conflict_resolution_policy sql_container_resource.vector_embedding_policy = sql_container.resource.vector_embedding_policy + sql_container_resource.full_text_policy = sql_container.resource.full_text_policy # client encryption policy is immutable sql_container_resource.client_encryption_policy = sql_container.resource.client_encryption_policy @@ -720,7 +728,8 @@ def cli_cosmosdb_sql_container_update(client, None, None, analytical_storage_ttl, - vector_embedding_policy): + vector_embedding_policy + full_text_policy): logger.debug('replacing SQL container') sql_container_create_update_resource = SqlContainerCreateUpdateParameters( @@ -2162,7 +2171,8 @@ def _populate_collection_definition(collection, default_ttl=None, indexing_policy=None, client_encryption_policy=None, - vector_embedding_policy=None): + vector_embedding_policy=None, + full_text_policy=None): if all(arg is None for arg in [partition_key_path, default_ttl, indexing_policy]): return False @@ -2185,6 +2195,9 @@ def _populate_collection_definition(collection, if vector_embedding_policy is not None: collection['vectorIndexingPolicy'] = vector_embedding_policy + + if full_text_policy is not None: + collection['fullTextPolicy'] = full_text_policy return True @@ -2197,7 +2210,8 @@ def cli_cosmosdb_collection_create(client, default_ttl=None, indexing_policy=DEFAULT_INDEXING_POLICY, client_encryption_policy=None, - vector_embedding_policy=None): + vector_embedding_policy=None, + full_text_policy=None): """Creates an Azure Cosmos DB collection """ collection = {'id': collection_id} @@ -2210,7 +2224,8 @@ def cli_cosmosdb_collection_create(client, default_ttl, indexing_policy, client_encryption_policy, - vector_embedding_policy) + vector_embedding_policy, + full_text_policy) created_collection = client.CreateContainer(_get_database_link(database_id), collection, options)