spring data

The cognitive collection is here.

First it was the cognitive dress, now Australian designer Jason Grech leveraged insights from Watson to create the world’s first cognitive couture collection for Melbourne Spring Fashion Week. Jason ran ten years of fashion data and real-time social posts through the Watson Visual Recognition API to analyze and predict trends that helped him find new ways to work with fabrics, color and textures. Jason also used Watson to infuse the couture with his love of architecture by matching architectural images with fashion images and taking inspiration from the lines, curves and corners. Now that’s some fashion forward thinking.

Explore the cognitive collection →

Match Array Value Elements with $elemMatch - MongoDB

I don’t get a lot of time to share these days, but when something really frustrates the crap out of me and then you finally get the understanding and code working, it’s something that needs to be shared.

example.

customers>names > first

 ………………………..> last

…………….>likes

createDate

when trying to validate arrays in mongo db, you can run into matching issues when arrays have multiple indexes but with matching array values in separate nodes.

  ie..   frank likes hockey and peter likes soccer.

if your criteria

{“customers.names.first”:“frank”,“customers.likes”:“soccer”}

matches this is why.

$elemMatch  will allow you to match the entire element in the array.

{“customers” : {“$elemMatch” : {names.first:“frank”,likes:“soccer”}}}

will not match.. which is the expected result.

Spring Data MongoDB elemMatch example:

 Criteria subCriteria = Criteria.where(“name.first”).is(name)

.and(“likes”)

.is(value);

criteria = Criteria

.where(“customers”).elemMatch(subCriteria)

.and(“createDate”)

.gte(startDate).lte(endDate);