MCPcopy Create free account
hub / github.com/cosdata/cosdata / create_collection_with_metadata

Function create_collection_with_metadata

tests/test-grpc.py:20–60  ·  view source on GitHub ↗

Test creating collection with metadata schema

(stub)

Source from the content-addressed store, hash-verified

18
19
20def create_collection_with_metadata(stub):
21 """Test creating collection with metadata schema"""
22 request = vector_service.CreateCollectionRequest(
23 name="test_metadata_collection",
24 description="Test collection with metadata schema",
25 dense_vector=vector_service.DenseVectorOptions(dimension=128, enabled=True),
26 sparse_vector=vector_service.SparseVectorOptions(enabled=False),
27 tf_idf_options=vector_service.TFIDFOptions(enabled=False),
28 metadata_schema=vector_service.MetadataSchema(
29 fields=[
30 vector_service.MetadataField(
31 name="category",
32 values=[
33 vector_service.FieldValue(string_value="electronics"),
34 vector_service.FieldValue(string_value="books"),
35 vector_service.FieldValue(string_value="clothing"),
36 ],
37 ),
38 vector_service.MetadataField(
39 name="rating",
40 values=[
41 vector_service.FieldValue(int_value=1),
42 vector_service.FieldValue(int_value=2),
43 vector_service.FieldValue(int_value=3),
44 vector_service.FieldValue(int_value=4),
45 vector_service.FieldValue(int_value=5),
46 ],
47 ),
48 ],
49 supported_conditions=[
50 vector_service.SupportedCondition(
51 op=vector_service.SupportedCondition.OperationType.AND,
52 field_names=["category", "rating"],
53 )
54 ],
55 ),
56 config=vector_service.CollectionConfig(
57 max_vectors=1000000, replication_factor=1
58 ),
59 )
60 return stub.CreateCollection(request)
61
62
63def create_simple_collection(stub, name="test_collection", dimension=128):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected