<?php

namespace Business\Search;



/**
 * 店铺service
 *
 * @date 2018-5-15
 * @author zhz
 */
class SearchServiceModel extends \Business\AbstractModel
{


    public function init()
    {

    }

    public function createShopKeeperOrders()
    {
        $elasticsToolElasticssearch=\Elastics\ElasticsToolModel::getInstance('orders');
        $res=$elasticsToolElasticssearch->createIndexDetail();
        return $res;
    }
    public function createShopKeeperIkOrders()
    {
        $elasticsToolElasticssearch=\Elastics\ElasticsToolModel::getInstance('orders');
        $delRes=$elasticsToolElasticssearch->deleteIndex();
        $createRes=$elasticsToolElasticssearch->createIkField();
        $postData=array(
            ['goodsName'=>"＂闺蜜＂崔顺实被韩检方传唤 韩总统府促彻查真相"],
            ['goodsName'=>"韩举行＂护国训练＂ 青瓦台:决不许国家安全出问题"],
            ['goodsName'=>"韩举行＂护国训练＂ 青瓦台:决不许国家安全出问题"],
            ['goodsName'=>"媒体称FBI已经取得搜查令 检视希拉里电邮"],
            ['goodsName'=>"村上春树获安徒生奖 演讲中谈及欧洲排外问题"],
            ['goodsName'=>"希拉里团队炮轰FBI 参院民主党领袖批其“违法”"],
        );
        $res=$elasticsToolElasticssearch->postBulkDoc($postData);
        return $res;
    }

    public function insertRows()
    {
        $elasticsToolElasticssearch=\Elastics\ElasticsToolModel::getInstance('orders');
        $row=array(
            'name'=>'陈传文',
            'age'=>46,
            'sex'=>'男',
        );
        $res=$elasticsToolElasticssearch->createDocument($row);
        return $res;
    }

    public function searchRows(){
        $elasticsToolElasticssearch=\Elastics\ElasticsToolModel::getInstance('orders');
        $query=array(
            'goodsName'=>'希拉里和韩国',
        );
        $res=$elasticsToolElasticssearch->searchMatch($query);
        return $res;
    }


    /**
     * 类实例
     *
     * @var \DAO\UserModel
     */
    private static $_instance = null;

    /**
     * 单例模式获取类实例
     *
     */
    public static function getInstance()
    {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }
}
