1. 參考網址:http://docs.prediction.io/templates/recommendation/dase/
  2. http://docs.prediction.io/templates/recommendation/reading-custom-events/ 更改event
  3.   bimap used here
      def predict(model: ALSModel, query: Query): PredictedResult = {
        // Convert String ID to Int index for Mllib
        model.userStringIntMap.get(query.user).map { userInt =>
          // create inverse view of itemStringIntMap
          val itemIntStringMap = model.itemStringIntMap.inverse
          // recommendProducts() returns Array[MLlibRating], which uses item Int
          // index. Convert it to String ID for returning PredictedResult
          val itemScores = model.recommendProducts(userInt, query.num)
            .map (r => ItemScore(itemIntStringMap(r.product), r.rating))
          new PredictedResult(itemScores)
        }.getOrElse{
          logger.info(s"No prediction for unknown user ${query.user}.")
          new PredictedResult(Array.empty)
        }
      }
    
    }
    
    
  4. "rate"=> "citation", "buy"=>"year"