Skip to content

Commit d517b85

Browse files
authored
Merge pull request #3 from amarsagare3/dev
add full text policy to azure CLI (no tests)
2 parents 74b2446 + 5f43e1f commit d517b85

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
SQL_VECTOR_EMBEDDING_POLICY_EXAMPLE = """--vector-embeddings "{\\"vectorEmbeddings\\": [{\\"path\\": \\"/vector1\\", \\"dataType\\": \\"float32\\", \\"dimensions\\": 2, \\"distanceFunction\\": \\"dotproduct\\" }]}"
4646
"""
4747

48+
SQL_FULL_TEXT_SEARCH_POLICY_EXAMPLE = """--full-text-policy "{\\"fullTextPaths\\": [{\\"path\\": \\"/ftPath1\\", \\"language\\": \\"en-US\\" }]}"
49+
"""
50+
4851
SQL_UNIQUE_KEY_POLICY_EXAMPLE = """--unique-key-policy "{\\"uniqueKeys\\": [{\\"paths\\": [\\"/path/to/key1\\"]}, {\\"paths\\": [\\"/path/to/key2\\"]}]}"
4952
"""
5053

@@ -167,6 +170,7 @@ def load_arguments(self, _):
167170
c.argument('partition_key_path', help='Partition Key Path, e.g., \'/properties/name\'')
168171
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)
169172
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)
173+
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)
170174
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)')
171175
c.argument('default_ttl', type=int, help='Default TTL. Provide 0 to disable.')
172176

@@ -222,6 +226,7 @@ def load_arguments(self, _):
222226
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)
223227
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)
224228
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)
229+
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)
225230
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)
226231
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)
227232
c.argument('max_throughput', max_throughput_type)

src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,10 @@ def _populate_sql_container_definition(sql_container_resource,
607607
partition_key_version,
608608
conflict_resolution_policy,
609609
analytical_storage_ttl,
610-
vector_embedding_policy):
610+
vector_embedding_policy,
611+
full_text_policy):
611612
if all(arg is None for arg in
612-
[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]):
613+
[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]):
613614
return False
614615

615616
if partition_key_path is not None:
@@ -641,6 +642,9 @@ def _populate_sql_container_definition(sql_container_resource,
641642
if vector_embedding_policy is not None:
642643
sql_container_resource.vector_embedding_policy = vector_embedding_policy
643644

645+
if full_text_policy is not None:
646+
sql_container_resource.full_text_policy = full_text_policy
647+
644648
return True
645649

646650

@@ -659,7 +663,8 @@ def cli_cosmosdb_sql_container_create(client,
659663
unique_key_policy=None,
660664
conflict_resolution_policy=None,
661665
analytical_storage_ttl=None,
662-
vector_embedding_policy=None):
666+
vector_embedding_policy=None,
667+
full_text_policy=None):
663668
"""Creates an Azure Cosmos DB SQL container """
664669
sql_container_resource = SqlContainerResource(id=container_name)
665670

@@ -672,7 +677,8 @@ def cli_cosmosdb_sql_container_create(client,
672677
partition_key_version,
673678
conflict_resolution_policy,
674679
analytical_storage_ttl,
675-
vector_embedding_policy)
680+
vector_embedding_policy,
681+
full_text_policy)
676682

677683
options = _get_options(throughput, max_throughput)
678684

@@ -695,7 +701,8 @@ def cli_cosmosdb_sql_container_update(client,
695701
default_ttl=None,
696702
indexing_policy=None,
697703
analytical_storage_ttl=None,
698-
vector_embedding_policy=None):
704+
vector_embedding_policy=None,
705+
full_text_policy=None):
699706
"""Updates an Azure Cosmos DB SQL container """
700707
logger.debug('reading SQL container')
701708
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,
707714
sql_container_resource.unique_key_policy = sql_container.resource.unique_key_policy
708715
sql_container_resource.conflict_resolution_policy = sql_container.resource.conflict_resolution_policy
709716
sql_container_resource.vector_embedding_policy = sql_container.resource.vector_embedding_policy
717+
sql_container_resource.full_text_policy = sql_container.resource.full_text_policy
710718

711719
# client encryption policy is immutable
712720
sql_container_resource.client_encryption_policy = sql_container.resource.client_encryption_policy
@@ -720,7 +728,8 @@ def cli_cosmosdb_sql_container_update(client,
720728
None,
721729
None,
722730
analytical_storage_ttl,
723-
vector_embedding_policy):
731+
vector_embedding_policy
732+
full_text_policy):
724733
logger.debug('replacing SQL container')
725734

726735
sql_container_create_update_resource = SqlContainerCreateUpdateParameters(
@@ -2162,7 +2171,8 @@ def _populate_collection_definition(collection,
21622171
default_ttl=None,
21632172
indexing_policy=None,
21642173
client_encryption_policy=None,
2165-
vector_embedding_policy=None):
2174+
vector_embedding_policy=None,
2175+
full_text_policy=None):
21662176
if all(arg is None for arg in [partition_key_path, default_ttl, indexing_policy]):
21672177
return False
21682178

@@ -2185,6 +2195,9 @@ def _populate_collection_definition(collection,
21852195

21862196
if vector_embedding_policy is not None:
21872197
collection['vectorIndexingPolicy'] = vector_embedding_policy
2198+
2199+
if full_text_policy is not None:
2200+
collection['fullTextPolicy'] = full_text_policy
21882201

21892202
return True
21902203

@@ -2197,7 +2210,8 @@ def cli_cosmosdb_collection_create(client,
21972210
default_ttl=None,
21982211
indexing_policy=DEFAULT_INDEXING_POLICY,
21992212
client_encryption_policy=None,
2200-
vector_embedding_policy=None):
2213+
vector_embedding_policy=None,
2214+
full_text_policy=None):
22012215
"""Creates an Azure Cosmos DB collection """
22022216
collection = {'id': collection_id}
22032217

@@ -2210,7 +2224,8 @@ def cli_cosmosdb_collection_create(client,
22102224
default_ttl,
22112225
indexing_policy,
22122226
client_encryption_policy,
2213-
vector_embedding_policy)
2227+
vector_embedding_policy,
2228+
full_text_policy)
22142229

22152230
created_collection = client.CreateContainer(_get_database_link(database_id), collection,
22162231
options)

0 commit comments

Comments
 (0)