henry
henry

Reputation: 607

How to do simple data mining in MongoDB?

I am new to MongoDB – just trying to learn it – not new to Java/SQL though. Suppose I have a shopping cart application developed in Java/MongoDB. Further suppose I have a document Order.java. So Order keeps usual order properties: Total amount, shipping address, credit card number and etc. as well as collection of line items. Now since order line items are part of order document they cannot be accesses individually without retrieving entire order. Right?
What I want it to show something like what Amazon does when you view a book: "People who bought this book – also bought so-and-so book". How do I determine that in MongoDB/Java application? In SQL it would be more or less simple query joining OrderLineItem to itself, or something along these lines, but there no joins in MongoDB. Should I load all Order documents into Java app, and then sort and match them in Java (essentially in memory). That does not seem practical if talking about millions of orders, is there anything else I can do?

Upvotes: 3

Views: 5467

Answers (2)

IrishDog
IrishDog

Reputation: 470

You could just use Apache Mahout https://mahout.apache.org/ . It's a very powerful machine learning library for distributed systems and NoSQL databases like Hadoop and MongoDB. It's open-source and written in Java.

Upvotes: 2

Raymond Lawrence
Raymond Lawrence

Reputation: 1

This type of query is facilitated by having all the line items in an array in the order document. If this query is done often, I'd but a batch-oriented process in place to reformat a copy of the data aimed at satisfying this query. When the going gets tough, there is always map Reduce.

Upvotes: 0

Related Questions