Reputation: 318
I am trying to create a test Cosmos and am a little confused about partition keys. Specifically what I am worried about is that when I add an item to the container I don't see any value being filled under the partition column.
What I am trying to do is set up a webscraper that would get text values. From that file I am choosing "Source" and "Date" as my partition columns so that I can have a somewhat even partition distribution.
I then created a Cosmos DB and loaded some test values:
During set up I wrote (minus the quotes) "/Source/Date" and I assumed that after I upload that item I would see those values be filled in. However, it looks like this test container is looking for one column called "/Source/Date".
I did a test where I only used "Source" as my partition key and it does auto fill in that value:
Am I missing something here? Can I only have one column as a partition key? If in first screenshot I see that "/Source/News" is empty does that mean that there is no "Partition key"?
I also did another test with having a unique key and it did work where I can't enter duplicate values of "Source/Date", but when I tried to put a comma in the field where the container is asking for a partition key I got an error.
Any help would be helpful.
Thank you
Upvotes: 1
Views: 614
Reputation: 136196
From that file I am choosing "Source" and "Date" as my partition columns so that I can have a somewhat even partition distribution.
I believe there's a bit of misunderstanding on your part regarding the partition key.
Currently you can't specify a partition key on two attributes. A partition key can only be created on a single attribute in your JSON document.
When you specify partition key essentially you're specifying a path to the JSON property in the document.
For example, considering you're setting the partition key as Source/Date
, your document would look something like the following:
{
"id": "your document id",
"Source": {
"Date": "some date value"
},
"Url": "blah blah",
"Text": "more blah blah",
"Formal_Source": "even more blah blah"
}
Upvotes: 4