imranmomin / Hangfire.AzureCosmosDb

Azure Cosmos DB storage provider for Hangfire
https://www.hangfire.io/
MIT License
17 stars 16 forks source link

Composite Index Exception #51

Open rfphill opened 2 years ago

rfphill commented 2 years ago

I get a constant exception: exception thrown: Exception: Microsoft.Azure.Documents.BadRequestException: Message: {"Errors":["The order by query does not have a corresponding composite index that it can be served from."]}

But there doesn't seem to be any way of telling what that composite index needs to be. I added "type" to the partition key because the app would blow up unless it was defined in the container but that doesn't seem to indicated anywhere either.

imranmomin commented 2 years ago

can you confirm if the composite indexes are created

https://github.com/imranmomin/Hangfire.AzureCosmosDb/blob/6e6b0400f02b4cf490edd2e29f278892ccaf8afa/src/CosmosDbStorage.cs#L259-L263

siazon commented 5 months ago

I had the same problem, after adding the following index, it now works

  "compositeIndexes": [
        [
            {
                "path": "/name",
                "order": "ascending"
            },
            {
                "path": "/created_on",
                "order": "ascending"
            }
        ]
    ]