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?

1 Answer 1

1

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

Use

searchQuery.put("arrayMine", new BasicDBObject("$in", Arrays.asList("xxx"))        
Sign up to request clarification or add additional context in comments.

Comments

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.