public function search($request, $response)
    {/*{{{*/
        $timeStart = XUtility::getStartTime();
        $type = $request->getRequest('type','all');
        $p = $request->getRequest('p',1);
        $kw = $this->getRequestKeyWord($request, $response);
        $this->addSearchLog($kw);
        $trimedKeyWord = $this->processKeyWord($kw);
        $result = SphinxSearchdBase::getNullResult();

        $allSearchd = new AllSearchd($trimedKeyWord);
        $keyWord = '';

        if($trimedKeyWord)
        {
            $allSearchd->setIndexType($type);
            $allSearchd->setPage($p);
            $allSearchd->query($trimedKeyWord);
            $result = $allSearchd->getSearchResult($type);
            if($type == 'all' || ($type == 'allarticle' && $p == 1))
            {
                $response->paperRes = $allSearchd->getDiseasePaperResult4Article();
            }
        }

        $response->trimedKeyWord = $kw;
        $response->keyWord = $keyWord;
        $response->allSearchd = $allSearchd;
        $response->result = $result;
        $response->type = $type;
        $response->p = $p;
        $response->timeSpan = XUtility::getCostTime($timeStart);
    }/*}}}*/
	private function searchBySphinx($request, $response, $kw, $p)
	{/*{{{*/
        $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor');
        $utf8Kw = mb_convert_encoding($kw, 'utf-8', 'gbk');
		$res = $doctorSearchd->query($utf8Kw, ($p - 1) * 15, 15);
        $searchResult = SearchResult::sphinxResult2searchResult($res, 'doctor', ($p - 1) * 15, 15);
        $response->totalPage = ceil($searchResult->total_found/$searchResult->pageSize);
		
		$results = array();
		foreach($searchResult->items as $item)
		{/*{{{*/
			$doctor = DAL::get()->find('doctor',$item->id);
			
            if($doctor->isNull() || $doctor->deleted > 0 )
            {
				continue;
			}
			
			$result = array();
			$result['id'] = $doctor->id;
			$result['name'] = $doctor->name;
			$result['title'] = $doctor->title;
			$result['hospital'] = $doctor->hospitalfaculty->hospital->name;
			$result['userid'] = $doctor->getUserId();
			$result['hospitalfacultyname'] = $doctor->hospitalfaculty->name ;
			$results[] = (object)$result;
		}/*}}}*/
		return $results;
	}/*}}}*/
    public function showlist($request, $response)
    {/*{{{*/
		$pageSize = 20;
		$kw = $request->k;
        $utf8Kw = mb_convert_encoding($kw, 'utf-8','gbk');
		$nowPage = $request->getRequest('pn', 1);
        $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor');
        $doctors = array();
        $res = $doctorSearchd->query($utf8Kw, ($nowPage-1)*$pageSize, $pageSize);
        if(false == empty($res['matches']))
        {
            foreach($res['matches'] as $item)
            {
                $doctor = DAL::get()->find('doctor',$item['id']);
                $doctors[] = $doctor;
            }
        }
        $response->totalCnt = $res['total'];
        $response->doctors = $doctors;
		$response->k = $request->k;
		$response->pageSize = $pageSize;
		$response->nowPage = $nowPage;
    }/*}}}*/
    /**
        * @brief 搜索订阅医生
        * @author lhl
        * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/subscription_searchdoctor?keyword=吴鸣&pageId=1&pageSize=15&userId=581662815 
        *
        * @param $keyword 搜索字段 
        * @Param $pageId 当前页码
        * @Param $pageSize 每页显示数
        *
        * @return array('doctorid', 'name', 'fullGrade', 'hospitalName', 'hospitalFacultyName', 'goodVoteCount', 'specialize', 'logoUrl')
     */
    public function searchDoctor($userId, $keyword, $pageId = 1, $pageSize = 15)
	{/*{{{*/
        if($userId != $this->currentUserId)
        {
            $this->setErrorCode(309);
            return 0;
        }
        if('' == trim($keyword))
        {
            $this->setErrorCode(450);
            return 0;
        }
        $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor');
        $utf8Kw = mb_convert_encoding($keyword, 'utf-8', 'gbk');
		$res = $doctorSearchd->query($utf8Kw, (int)(($pageId - 1 ) * $pageSize), (int)($pageSize));
        $searchResult = SearchResult::sphinxResult2searchResult($res, 'doctor', (int)(($pageId - 1 ) * $pageSize), (int)($pageSize));
		
		$myDoctorList = SubscriptionClient::getInstance()->getMyDoctors($userId);
        $subscriptionDoctor = array();
        foreach($myDoctorList as $myDoctor) 
        {
           $subscriptionDoctor[$myDoctor->doctor->id] = $myDoctor->id;
        }

		$results = array();
		foreach($searchResult->items as $item)
		{
			$doctor = DAL::get()->find('doctor',$item->id);
			
            if(false == $doctor->isNull() && $doctor->deleted == 0)
            {
                $result = $allHospitalFacultyNames = array();
                $result['doctorid'] = $doctor->id;
                $result['name'] = $doctor->name;
                $result['fullGrade'] = implode(" ",array($doctor->grade,$doctor->educateGrade));
                $primaryDoctors = DAL::get()->find_all_byPrimaryIds('Doctor', array($doctor->primaryId));
                foreach ($primaryDoctors as $primaryDoctor)
                {
                    $allHospitalFacultyNames[] = $primaryDoctor->hospitalfaculty->hospital->commonName.' '.$primaryDoctor->hospitalfaculty->name;
                }
                $result['hospitalName'] = implode("\n", $allHospitalFacultyNames);
                $result['hospitalFacultyName'] = '';
                $result['goodVoteCount'] = $doctor->goodVoteCount;
                $result['specialize'] = $doctor->specialize;
                $result['logoUrl'] = $doctor->getHeadImageForMobile();
                $result['mydoctorid'] = '';
                if(isset($subscriptionDoctor[$doctor->id]))
                {
                    $result['mydoctorid'] = $subscriptionDoctor[$doctor->id];
                }
                $results[] = $result;
            }
		}
        $this->content = $results;
        $this->pageInfo = array('pages' => ceil($searchResult->total_found / $searchResult->pageSize), 'pagesize' => $pageSize, 'nowpage' => $pageId, 'total' => $searchResult->total_found);
	}/*}}}*/
 private function searchBySphinx($kw)
 {
     /*{{{*/
     $diseaseSearchd = SphinxSearchdBase::createSearchdByType('Disease');
     $utf8Kw = mb_convert_encoding($kw, 'utf-8', 'gbk');
     $searchResult = $diseaseSearchd->getSearchResultByQuery($utf8Kw, 0, 10);
     $searchResult->convetToGbk();
     $results = array();
     if ($searchResult->total_found > 0) {
         foreach ($searchResult->items as $item) {
             $disease = DAL::get()->find('disease', $item->id);
             $diseaseInfo = new stdclass();
             $diseaseInfo->name = $disease->name;
             $diseaseInfo->key = $disease->key;
             $diseaseInfo->flowCntLevel2 = $this->getFlowCnt($disease->id, FlowContentMark::LEVEL_2);
             $diseaseInfo->flowCntLevel3 = $this->getFlowCnt($disease->id, FlowContentMark::LEVEL_3);
             $diseaseInfo->articleCntLevel3 = $this->getArticleCntLevel3($disease->id);
             $results[] = $diseaseInfo;
         }
     }
     return $results;
 }
    public function searchDisease4Booking($userId, $deviceToken, $diseaseName, $type)
    {/*{{{*/
        $type = AppBookingRef::TYPE_DISEASE;
        if(empty($deviceToken) && empty($userId))
        {
            $this->setErrorCode(327);
            return 0;
        }
                 
        $myBookingList = MobileBookingClient::getInstance()->showBookedDisease($userId, $deviceToken, $type);
        
        $diseaseSearchd = SphinxSearchdBase::createSearchdByType('Disease');
        $searchResult = $diseaseSearchd->getSearchResultByQuery(mb_convert_encoding($diseaseName, 'utf-8','gbk'),0,10);
        $searchResult->convetToGbk();

        $infos = array();
		foreach($searchResult->items as $item)
		{
			$disease = DAL::get()->find('disease',$item->id);
			if($disease->isNull())
			{
				continue;
			}
			$info['diseaseName'] = $disease->name;
			$info['diseaseId'] = $disease->id;
			$info['bookingStatus'] = (array_key_exists($disease->id, $myBookingList)) ? '1' : '0';
			$infos[] = $info;
		}                                    
        $this->content = $infos;     
    }/*}}}*/