Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
How can I create index on CosmosDb for a single element of key-value pair array

I use Azure CosmosDb with MongoDb Api and got collection of documents with a structure bellow. I have to filter documents by parameter, ex.

x => x.Parameters.Any(xx => xx.Key == ParameterNames.ShiftId && (int)xx.Value == shiftId)

It seems to me to better performance I need to create index, but I cannot find any information how can I do it.

{
"_id": "08d8c696-2b7b-f227-d5dd-0647a8d51c1c",
"State": 2,
"Created": {
    "$date": "2021-02-01T09:45:54.986Z"
},
"TailId": "e8fb236e-4d48-417b-bf5a-73f1d48fe239",
"Parameters": [{
    "k": "ShiftId",
    "v": 181
}, {
    "k": "Id",
    "v": "147814878155"
}, ....
]

}

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

For the Cosmos DB Mongo API, you could try adding a wildcard index on Parameters as described in the docs.

If you are in a position to change your model, you'll likely have better performance by refactoring the Parameters array into properties closer to the document root. For example:

{
  "_id": "08d8c696-2b7b-f227-d5dd-0647a8d51c1c",
  "State": 2,
  ...
  "ShiftId": 181,
}

or

{
  "_id": "08d8c696-2b7b-f227-d5dd-0647a8d51c1c",
  "State": 2,
  ...
  Parameters: {
    "ShiftId": 181,
    "Id": "147814878155" 
  }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!