2

According to the answer provided in this link: Find document with array that contains a specific value, i have tried getting the items in java using this statement

searchQuery.put("arrayMine", new BasicDBObject("$in","[xxx]"));
OR
searchQuery.put("arrayMine", new BasicDBObject("$in","xxx"));

But it keeps saying the $in value must be an array while my arrayMine is an array. What should be the correct syntax in java?

Community
  • 1
  • 1
Chit Khine
  • 830
  • 1
  • 13
  • 34

1 Answers1

1

Both variants you have are treating the value of BasicDBObject as String.

Use

searchQuery.put("arrayMine", new BasicDBObject("$in", Arrays.asList("xxx"))        
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
s7vr
  • 73,656
  • 11
  • 106
  • 127