I am adding simple search functionality for my users in my app, and I am strongly considering using Azure CosmosDB. Documents in my Cosmos database (Azure) represent phone calls, and look like this:
{
"id": "JKEeW3aebSEAzUA",
"partitionKey": "191625028",
"ownerId": "191625028",
"callTime": "2020-06-12T22:13:18.271+00:00",
"direction": "Inbound",
"action": "Phone Call",
"result": "Accepted",
"callers": [
{
"phoneNum": "9182914018",
"name": "JENKS OK",
"location": "Jenks, OK"
},
{
"phoneNum": "9189406524",
"name": "Main IVR",
"location": null
},
{
"phoneNum": null,
"name": "Main IVR",
"location": null,
}
]
}
I am going to provide search-ability based on the nested properties phoneNum
, name
, and location
within each callers
item. I am considering using this query:
SELECT c.id,a.phoneNum,c.callers
FROM c join a in c.callers
where CONTAINS(a.phoneNum, '4018')
Is this the most efficient way to perform this kind of search? I am open to restructuring my documents to make searching within those fields faster. Some things to note:
- It's a multi-tenant system, and we are using a "partition-per-tenant" scheme in this particular database.
- Some partitions/tenants will have 1,000,000+ call records and 3,000,000 - 4,000,000 nested caller records when the data import is complete.
I am new to Azure CosmosDB. Currently we provide limited search functionality similar to this via SQL Server. This structure is identical to our structure in SQL Server (parent call records, child caller records).