0

I am considering DocumentDB, specially for the ability to bring my MongoDB code to work with it. DocumentDB is very fast and affordable, but I am having some difficulty:

I have this code that works on MongoDB:

var categoriesList = await Pessoa.Distinct<string>("Enderecos.Cidade", new BsonDocument()).ToListAsync();

This Exception happens:

MongoCommandException: Command distinct failed: Command is not supported.

On this code:

var cidades = Pedido.AsQueryable().Where(d => d.DocType == new Pedido().DocType)
                 .GroupBy(p => p.Cliente.Enderecos[0].Cidade)
                 .ToList();

It gives this exception:

MongoDB.Driver.MongoCommandException: 'Command aggregate failed: '$group' is not supported.'

What can I do to make it work on DocumentDB? Is there any simple equivalent code I can do to have this feature? Distinct / Group by on DocumentDB?

DocumentDB must support this. I will probably stay on Mongo until they release these features.

1

1 Answer 1

2

Tony-

Support for GroupBy is coming. In the mean time, here are a few ways you can implement the same functionality:

  • By enumerating the distinct values, then aggregating them one by one
  • By using a streaming pattern on top of DocumentDB’s change feed (materialize the aggregates on write)
  • By using Spark + DocumentDB
Sign up to request clarification or add additional context in comments.

1 Comment

Great. Thank you for fast answer. All my workload is on Azure. DocumentDB is very fast and affordable, I would like to use it, but as I said, my software uses that two commands, that did not work after I migrated from MongoDB to DocumentDB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.