Relate it is a simple and easy way to relate one item to several others. Once several items are related, you can enquire: “For this item, what are the most frequently related items.”

An example use for this functionality is on a web site to create relations between the items the people are purchasing, and presenting users browsing those items with a “Frequently Purchased With” section. This is often referred to as “Also Bought With”, and is sometimes an aid to what is known as “Cross Selling”.

For example, Imagine a person purchases the books: ‘Java Performance Tuning’, ‘Akka Concurrency’ and ‘Java concurrency in Practice’ at the same time. When future user is browsing ‘Java Performance Tuning’, you can present that user with a set related items that this book is most “Frequently Purchased With”.

This application has 3 parts to it:

The indexing and searching components (web applications) make use of the Disruptor library.

The search technology Elasticsearch provides the storage, and searching mechanism for providing the related product search.

The Indexing and Searching components do not need to directly be used. In other words you can just post data in the relevant format into elasticsearch, and then perform searching directly against elasticsearch to obtain the most frequently related items. However, it is the Indexing and Searching components that provide a means of batching indexing and searching requests that are being send to elasticsearch.


Latest Version

The lastest version is 1.1.0 ( searching.war | indexing.war)

Requirements


Indexing

The index web application is POSTed data containing a group of related items, i.e. for example a purchase containing several items.

curl -H"Content-Type:text/json" -XPOST -v http://localhost:8080/indexing/index -d '
{
   "channel":"de",
   "site":"amazon",
   "items":[
      {
         "id":"1",
         "type":"map"
      },
      {
         "id":"2",
         "type":"compass"
      },
      {
         "id":"3",
         "type":"torch"
      },
      {
         "id":"4",
         "type":"torch",
         "channel":"uk"
      }
   ]
}'

Searching

Find the items that are mostly purchased with product 1, filtering the results to that of “torches” (type=torch):

curl -v -N http://localhost:8080/searching/frequentlyrelatedto/1?type=torch

The result is:

{
    "response_time": "11", 
    "results": [
        {
            "frequency": "1", 
            "id": "4"
        }, 
        {
            "frequency": "1", 
            "id": "3"
        }
    ], 
    "size": "2", 
    "storage_response_time": "2"
}

This can be reduced event further to search for torches, just in channel uk, which is:

curl -v -N "http://localhost:8080/searching/frequentlyrelatedto/1?type=torch&channel=uk"

Which will result in just the one related item:

{
    "response_time": 3, 
    "results": [
        {
            "frequency": "1", 
            "id": "4"
        }
    ], 
    "size": "1", 
    "storage_response_time": 1
}