How to provide index hint for updating a document using update
parikmaan opened this issue · 0 comments
How to provide index hint for updating a document using update.
Ex:
friends collection has a document with field name and value as joe (all lower case). There is a case insensitive index using { locale : 'en', strength : 1 }
for field name.
Find query works fine using QueryModifier:
Collection.find("{name: #}", "Joe") .with(new QueryModifier() { @Override public void modify(DBCursor cursor) { cursor.setCollation(Collation.builder().collationStrength( CollationStrength.PRIMARY).locale("en").build()); } }).as(Friends.class));
But when trying to update a document there is no option to provide collation or index hint
friends.update("{name: 'Joe'}").with("{$inc: {age: 1}}");
Above update updates 0 document because it is not able to find that document.
Is there a work around for this problem?