Overview

In the Indexing section, we saw that the related items POST document is constructed in to many small documents and stored in elasticsearch. These tiny documents contain the related-with field. It is this json element related-with, that will be used during searching, to provide faceting.
This faceting that allows us to say:

  • For this id, what are the 5 top most frequently related-with ids.

For example for previously indexed POST request:

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"
      }
   ]
}'

The search web application is then called to request the frequently related items for a product (Item with id 1 in this case):

curl -v -N http://localhost:8080/searching/frequentlyrelatedto/1

This returns json data containing the list of items (their id’s) that are frequently related to that item:

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

}