Azure-cosmos-dotnet-v2: Question: how to OrderBy on composite indexes?

Created on 2 Jul 2019  路  4Comments  路  Source: Azure/azure-cosmos-dotnet-v2

In release 2.4.0 CompositeIndexes can now be defined for collections. I am unsure how to leverage these with the LINQ interface.

For example, with the composite index for Foo and Bar I would have the following indexing policy:

{
    ...
    "compositeIndexes":[  
        [  
            {  
                "path":"/Foo",
                "order":"ascending"
            },
            {  
                "path":"/Bar",
                "order":"ascending"
            }
        ]
    ]
}

I would expect to the collection with something like:

query.OrderBy(e => new { e.Foo, e.Bar});
// or
query.OrderBy(e => e.Foo).ThenBy(e  => e.Bar);

I would be happy with any other possible way of getting something achieved with the same effect of ordering composite indexes.

enhancement planned

Most helpful comment

Multi order in LINQ is not supported yet , work item is in queue but not prioritized yet. Will keep this thread open to track it

All 4 comments

Will get back to you on this

Multi order in LINQ is not supported yet , work item is in queue but not prioritized yet. Will keep this thread open to track it

@simplynaveen20 is there any workaround to this issue until it's available as part of the SDK?

Looks like it's made it into the v3 SDK: https://github.com/Azure/azure-cosmos-dotnet-v3/pull/801

Was this page helpful?
0 / 5 - 0 ratings