Open Closed

CosmosDB error migrating "The index path corresponding to the specified order-by item is excluded" #7312


User avatar
0
pelc.stefan created
  • ABP Framework version: v8.1.3

  • UI Type: Blazor Server

  • Database System: MongoDB

  • Tiered (for MVC) or Auth Server Separated (for Angular): no

  • Exception message and full stack trace:

  • MongoDB.Driver.MongoCommandException HResult=0x80131500 Message=Command aggregate failed: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 9938fd57-cea7-4dca-ad52-633fa90d97b1; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 9938fd57-cea7-4dca-ad52-633fa90d97b1; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 9938fd57-cea7-4dca-ad52-633fa90d97b1; Reason: (Message: {"Errors":["The index path corresponding to the specified order-by item is excluded."]} ActivityId: 9938fd57-cea7-4dca-ad52-633fa90d97b1, Request URI: /apps/cb9a5e6a-26b3-40ae-83c4-f2e6137ce7ce/services/3e32c5c8-fe2d-448f-b431-cd09a5a1b374/partitions/8566e1b0-475f-445b-84b4-f842641e1b74/replicas/133622193936236157p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0);););. Source=MongoDB.Driver.Core StackTrace: at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage) at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol1.<ExecuteAsync>d__20.MoveNext() at MongoDB.Driver.Core.Servers.Server.ServerChannel.<ExecuteProtocolAsync>d__201.MoveNext() at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.<ExecuteAsync>d__31.MoveNext() at MongoDB.Driver.Core.Operations.ReadCommandOperation1.<ExecuteAsync>d__8.MoveNext() at MongoDB.Driver.Core.Operations.AggregateOperation1.<ExecuteAsync>d__65.MoveNext() at MongoDB.Driver.Core.Operations.AggregateOperation1.<ExecuteAsync>d__64.MoveNext() at MongoDB.Driver.OperationExecutor.<ExecuteReadOperationAsync>d__31.MoveNext() at MongoDB.Driver.MongoCollectionImpl1.<ExecuteReadOperationAsync>d__1011.MoveNext() at MongoDB.Driver.MongoCollectionImpl1.<AggregateAsync>d__251.MoveNext() at MongoDB.Driver.MongoCollectionImpl1.<UsingImplicitSessionAsync>d__1091.MoveNext() at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExecutableQuery3.<ExecuteAsync>d__14.MoveNext() at MongoDB.Driver.IAsyncCursorSourceExtensions.<ToListAsync>d__161.MoveNext() at Volo.Abp.LanguageManagement.MongoDB.MongoLanguageRepository.<GetListAsync>d__2.MoveNext() at Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__141.MoveNext() at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.<ProceedAsync>d__7.MoveNext() at Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__2.MoveNext() at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__31.MoveNext() at Volo.Abp.LanguageManagement.Data.LanguageManagementDataSeeder.<SeedAsync>d__16.MoveNext() at Volo.Abp.LanguageManagement.Data.LanguageManagementDataSeedContributor.<SeedAsync>d__2.MoveNext() at Volo.Abp.Data.DataSeeder.<SeedAsync>d__7.MoveNext() at Castle.DynamicProxy.AsyncInterceptorBase.<ProceedAsynchronous>d__13.MoveNext() at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.<ProceedAsync>d__7.MoveNext() at Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__2.MoveNext() at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.<InterceptAsync>d__2.MoveNext() at Tag3.Backend.Data.BackendDbMigrationService.<SeedDataAsync>d__11.MoveNext() in D:\1701apps.tag3.io.vNext\Backend\Tag3.Backend\src\Tag3.Backend.Domain\Data\BackendDbMigrationService.cs:line 97 at Tag3.Backend.Data.BackendDbMigrationService.<MigrateAsync>d__9.MoveNext() in D:\1701apps.tag3.io.vNext\Backend\Tag3.Backend\src\Tag3.Backend.Domain\Data\BackendDbMigrationService.cs:line 47 at Tag3.Backend.DbMigrator.DbMigratorHostedService.<StartAsync>d__3.MoveNext() in D:\1701apps.tag3.io.vNext\Backend\Tag3.Backend\src\Tag3.Backend.DbMigrator\DbMigratorHostedService.cs:line 36 at Microsoft.Extensions.Hosting.Internal.Host.<<StartAsync>b__15_1>d.MoveNext() at Microsoft.Extensions.Hosting.Internal.Host.<ForeachService>d__181.MoveNext() at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>g__LogAndRethrow|15_3(<>c__DisplayClass15_0& ) at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__15.MoveNext() at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() at Tag3.Backend.DbMigrator.Program.<Main>d__0.MoveNext() in D:\1701apps.tag3.io.vNext\Backend\Tag3.Backend\src\Tag3.Backend.DbMigrator\Program.cs:line 28

  • Steps to reproduce the issue: Create a solution using the AbpSuit and run the DbMigrator

Hello,

i followed this guide: https://community.abp.io/posts/using-cosmosdb-with-the-abp-framework-via-mongodb-api-x47bjeik on using my cosmosdb within ABP, but i receive the given error on DbMigration. Within this guide the same error has been stated in the comments more than a year ago, can anyone help me out?

the mongodb transactions are disabled by default.

i tried to switch to the EF-Provider but wasn't able to achive this, are there any guides? I found this https://docs.abp.io/en/abp/latest/Entity-Framework-Core-Other-DBMS but there is no clue on how to achive this using a cosmosDb.

Any help would be appriciated.

Thanks, Stefan


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi

    CosmosDB does not fully implement the MongoDB API. Sorting is one of the limitations of using CosmosDB for MongoDB. For you to sort a collection you must index the field you are sorting with.

    See: https://stackoverflow.com/questions/56988743/using-the-sort-cursor-method-without-the-default-indexing-policy-in-azure-cosm

    You need to create the index manually

  • User Avatar
    0
    pelc.stefan created

    Hi

    CosmosDB does not fully implement the MongoDB API. Sorting is one of the limitations of using CosmosDB for MongoDB. For you to sort a collection you must index the field you are sorting with.

    See: https://stackoverflow.com/questions/56988743/using-the-sort-cursor-method-without-the-default-indexing-policy-in-azure-cosm

    You need to create the index manually

    Thanks for the really quick answer and the provided link, how can i create that index? The migrator creates the databases and collections, is there any point within the code where i should create the wildcard index? I dont't know where the sort is beeing applied ...

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Considering that ABP may sort all fields in UI, you can create indexes for all fields.

    Here is the document(8.2 version):

    https://docs.abp.io/en/abp/8.2/MongoDB#configure-indexes-and-createcollectionoptions-for-a-collection

  • User Avatar
    0
    pelc.stefan created

    I'm sorry but i can't find ConfigureIndexes() in my IMongoModelBuilder, is it an extension somewhere? Am i missing something?

    my refs: using MongoDB.Driver; using Volo.Abp.Data; using Volo.Abp.MongoDB;

    Thanks

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Because this is a new feature in 8.2.0

    You can upgrade your project version to 8.2.0-rc.5

  • User Avatar
    0
    pelc.stefan created

    Oh my bad, i didn't see that, thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11