class TBRDaoESImp extends BaseDaoESImp implements TBRDao {

    @Override
    public double getTBRRatio(TargetingChannel targetingChannel) throws ESConnectionException
    {
        double ratio = 0;

        if (!targetingChannel.hasMultiValues())
        {
            return 1;
        }

        try
        {
            /**
             * Get the query count
             */
            BoolQueryBuilder boolQueryBuilder = createBoolQueryForTBR(targetingChannel, false);
            double queryCountResult = getSumForQuery(boolQueryBuilder);
            if (queryCountResult == 0)
            {
                ratio = 0;
            }
            else
            {
                /**
                 * Get the total count
                 */
                boolQueryBuilder = createBoolQueryForTBR(targetingChannel, true);
                double total = getSumForQuery(boolQueryBuilder);

                /**
                 * If total is zero, means such single value attributes do not exist, hence ratio is zero.
                 *
                 */
                if (total != 0)
                {
                    ratio = queryCountResult / total;
                }
            }
        }
        catch (IOException e)
        {
            LOGGER.error(e.getMessage());
            throw new ESConnectionException(e.getMessage());
        }
        LOGGER.info("tbr ratio={}", ratio);
        return ratio;
    }

    public  TBRDaoESImp(Properties properties);

}