Getting started for Java developers

From the Directed Edge Developer Base
Jump to: navigation, search

Java.png

Directed Edge makes integrating with our recommendations engine easy with Java. We provide bindings that handle all of the communication with our server transparently using normal Java objects.

Getting started

  • Introduction to Recommendations is a good starting point if you're wondering how recommendations work or what they're useful for.
  • API Concepts explains some of the basics of hour our API works and introduces the concepts of items, tags and links, also explained briefly below.
  • Grab the Java bindings from GitHub and copy the file named Java/dist/com.directededge.jar into your project. You'll also need the included com.noelios.restlet.jar and org.restlet.jar from Java/dist/lib.

Data modeling

Items and links

To model the data from your site, you'll need to figure out what your items are. Usually they're things like users, products and articles. We represent a relationship between items by links. So, if you have Bob Dylan's "Blonde on Blonde" that you want to say was bought by "John Doe", you create a link from "John Doe" to "Blonde on Blonde".

Identifiers

Usually we don't need to actually know the names of those items — they just need a unique identifier. Typically that's something like customer1 and product1. Most people just use the ID field from their own database. So if you have a MySQL table named products and Blonde on Blonde is at the row with ID 42 then you'd just use product42 as your identifier for that product.

Tags

Items also have tags, so John Doe would probably have a user tag and Blonde on Blonde would have a product tag. Tags don't weigh into the ranking at all — they're just used so that you can filter the sort of results you'd like to get. So if you want to show related products, you'd run a query looking for things with the tag product.

Querying for recommendations

We offer two primary sorts of recommendations, called related and recommended:

Related is for example if you have one product and you want to find similar products, or a user and want to find similar users. To find products related to Blonde on Blonde you'd send a related query for that item, looking for things tagged product.

Recommended is for doing personalized recommendations, e.g. Products Bob is likely to be interested in... To do a recommended query, you would send a request for the item that corresponds to Bob looking for things that are tagged product.

API Documentation

You can find full documentation for the bindings classes here.

Examples

Currently there's no ExampleStore example like there are for PHP, Python and Ruby, but since the bindings follow very closely to the bindings in those languages, it's probably still worth your time to glance at one of those.

You'll also find several files in Java/test in the bindings that should give you a bit of an idea of how the Java API fits together.

Further Reading

If you want to dig deeper into how the web services work — the REST API, XML Format and Web Services Examples articles explain what's going on behind the scenes when you use our bindings.