• Post Reply Bookmark Topic Watch Topic
  • New Topic

Some interesting error

 
Paritosh H Chandorkar
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I tried out the following code from the "MongoDB:The Definitive Guide".



I was setting up the criteria for the query.But it gave the error

"com.mongodb.MongoException: Can't canonicalize query: BadValue $all needs an array"

I wonder if it is the driver issue.If so the book needs to be updated.

Would like to have your comments

(Bartender cleanup: added code tags. Please UseCodeTags ←click that link to see how)
 
Junilu Lacar
Marshal
Posts: 10396
124
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of the driver are you using? And what version of MongoDB? You should probably check the current driver documentation to see the recommended way to do that. As far as I can tell, that's not the way to do it with the 3.0.0 version of the Java driver. And yes, the value for "$all" should be an array. The driver might take a list though. Give it a try.

I'm taking the course at MongoDB university right now and we are using version 3.0.0. I just completed an exercise where we had to do something similar. If you want to use $all, you have to do something like this:

Or something like that.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!