1,'<10分钟'=>2,'<15分钟'=>3,'<30分钟'=>4, '<60分钟'=>5,'<90分钟'=>6,'<2小时'=>7,'<数小时'=>8, '<一天'=>9,'<数天'=>10,'2小时以上'=>10,'>2小时'=>10 ); $gongyi_ar_2 = array( '煮'=>194,'炒'=>192,'蒸'=>156,'烧'=>149,'拌'=>141, '炖'=>124,'炸'=>153,'煎'=>129,'烘焙'=>220,'烤'=>130, '酱'=>132,'焖'=>144,'烩'=>127,'扒'=>112,'爆'=>114, '卤'=>138,'砂锅'=>148,'炝'=>140,'腌'=>134,'冻'=>136, '熘'=>142,'熏'=>139,'汆'=>123,'拔丝'=>113,'煲'=>147, '榨汁'=>253,'灼'=>193,'烙'=>252,'微波'=>251,'泡'=>256, '腊'=>133,'糖蘸'=>119,'干锅'=>255,'焗'=>262,'干煸'=>260, '煨'=>261,'其他'=>259 ); $kouwei_ar_2 = array( '咸鲜味'=>160,'家常味'=>168,'甜味'=>185,'香辣味'=>187, '酸甜味'=>182,'酸辣味'=>180,'麻辣味'=>177,'苦香味'=>174, '五香味'=>186,'酱香味'=>170,'奶香味'=>257,'咖喱味'=>173, '蒜香味'=>183,'鱼香味'=>188,'茄汁味'=>179,'葱香味'=>162, '椒麻味'=>171,'姜汁味'=>169,'怪味'=>165,'果味'=>166, '芥末味'=>172,'红油味'=>167,'豆瓣味'=>164,'麻酱味'=>176, '黑椒味'=>264,'酸味'=>266,'糊辣味'=>265,'其他'=>189 ); $make_step_ar_2 = array( '<3步' => 3,'<6步' => 6,'<9步' => 9,'<14步' => 14, '<19步' => 19,'<24步' => 24,'<29步' => 29,'30' => 30 ); $cid = gp('cid');//分类id $page_size = gp('page_size');//页大小 $no_official = gp('no_official');//去除美食杰小编的菜谱 if(empty($page_size)){ $page_size = 21; } $wordarr = explode(" ",$words); $is_yx = gp('is_yx'); $filter = gp('filter'); $nd = gp('need_third'); if(empty($nd)){ $nd = 1; }else{ $nd = 2; } $filter = json_decode($filter,true); if($page < 1 || !is_numeric($page)){ $page=1; } $sortby = array(); $sort = gp('order');//排序字段 -hot video -fav_num -new if($sort){ $sort_arr = str_split($sort); if($sort_arr[0]=='-'){ $orderarr = 'desc' ; }elseif($sort_arr[0]=='+'){ $orderarr = 'asc' ; }else{ $orderarr = 'desc' ; } $skey = str_replace('+','',str_replace('-','',$sort)); if($skey=='hot'){ //$sortby[] = array('recipe_type'=>array('order'=>'desc')); } $sort_ars = array('hot'=>array('_score'=>array('order'=>$orderarr)),'hard' => array('make_amount'=>array('order'=>$orderarr)),'time' =>array('make_time'=>array('order'=>$orderarr)),'new'=>array('cid'=>array('order'=>$orderarr)),'fav_num'=>array('fav_num'=>array('order'=>$orderarr))); if(array_key_exists($skey,$sort_ars)){ $sortby[] = $sort_ars[$skey]; } if($skey!='hot'){ $sortby[] = array('_score'=>array('order'=>'desc')); } } $post_filter = array(); $post_filter[] = array("range" => array('cid' => ['gte'=>100000])); if($sort=='video'){ $post_filter[] = array("term" => array('recipe_type' => '3')); } $should[] = array("term" => array('checked' => '1')); $should[] = array("term" => array('checked' => '11')); $should[] = array("term" => array('checked' => '12')); if(!empty($filter)){ if(isset($filter['time'])){ if(in_array($filter['time'],$make_time_ar_2)) { $post_filter[] = array("term" => array('make_time' => $filter['time'])); } } if(isset($filter['step_amount'])){ if(in_array($filter['step_amount'],$make_step_ar_2)) { $post_filter[] = array("term" => array('make_amount' => $filter['step_amount'])); } } if(isset($filter['taste'])){ if(in_array($filter['taste'],$kouwei_ar_2)) { $post_filter[] = array("term" => array('kw' => $filter['taste'])); } } if(isset($filter['technology'])){ if(in_array($filter['technology'],$gongyi_ar_2)) { $post_filter[] = array("term" => array('gy' => $filter['technology'])); } } } $sql = "select * from app_recipe_category where `title`='$words'"; $category = app_recipe_category::select($sql,app_recipe_category::MODEL_NAME); if($cid || !empty($category)){ $fields = array( "owner_ztids_cn^10", "new_tags_cn^10", "category^10", "tag^8", "title" ); }else{ $fields = array( "title^10", "gongxiao^6", "zhuliao^6", "owner_ztids_cn", "new_tags_cn", "tag", "yx_tags" ); } $h_score = "100%"; $is_mix_tag = 0; if($is_mix_tag){ $h_score = "10%"; } if($is_yx){ $fields = array( "yx_tags" ); $sortby = array(); $sortby[] = array('cid'=>array('order'=>'desc')); $h_score = "100%"; } $words = str_replace('菜谱','',$words); $multi_match = array( "query" => $words, "fields" => $fields, "type"=> "best_fields", "tie_breaker"=> 0.3, "minimum_should_match"=>$h_score ); $rekey = 'online_rank_recipe_all'; $node = 'node214'; $must_not = array( array( "term" => array("befrom" => "gen_url") ), array( "term" => array('checked' => '20') ) ); if(!empty($no_official)){ $must_not[] = array( "term" => array("writer_id" => "113291") ); } $query = [ "function_score"=> [ "functions"=> [ [ "field_value_factor"=> [ "field"=> "rank_score", "modifier"=>"log1p", "factor"=>2 ] ] ], "query"=> [ "filtered"=> [ "query"=> [ "multi_match"=> $multi_match ], "filter"=> [ "bool"=> [ "must" => $post_filter, "must_not" => $must_not, "should" => $should ] ] ] ] ] ]; $recipe_list = elastic_search::map_search($query,$sortby,$page,$page_size,$node,$rekey); if(!empty($recipe_list['hits']['hits'])){ $relist = $recipe_list['hits']['hits']; $total = $recipe_list['hits']['total']; $total_page = ceil($total/$page_size); }else{ $multi_match = array( "query" => $words, "fields" => $fields, "type"=> "best_fields", "tie_breaker"=> 0.3, "minimum_should_match"=>"70%" ); $query = [ "function_score"=> [ "functions"=> [ [ "field_value_factor"=> [ "field"=> "rank_score", "modifier"=>"log1p", "factor"=>2 ] ] ], "query"=> [ "filtered"=> [ "query"=> [ "multi_match"=> $multi_match ], "filter"=> [ "bool"=> [ "must" => $post_filter, "must_not" => $must_not, "should" => $should ] ] ] ] ] ]; $recipe_list = elastic_search::map_search($query,$sortby,$page,$page_size,$node,$rekey); if(!empty($recipe_list['hits']['hits'])){ $relist = $recipe_list['hits']['hits']; $total = $recipe_list['hits']['total']; $total_page = ceil($total/$page_size); }else{ $relist = array(); } } $page_show_info = seo_common::page_pc($total,$page_size,5,$current_url,'w'); $about_attr = array(); foreach($relist as $val) { $bz_recipe = array(); if($val['_source']['recipe_type']==1){ $titlepic = !empty($val['_source']['titlepic'])?$val['_source']['titlepic']:$val['_source']['newsphoto']; }else{ $titlepic = !empty($val['_source']['newsphoto'])?$val['_source']['newsphoto']:$val['_source']['titlepic']; } if($val['_source']['user_recipe_id']){ $user_recipe_kv=user_recipe::get_by_id($val['_source']['user_recipe_id']); } if(!empty($user_recipe_kv['description'])){ $description=$user_recipe_kv['description']; }else{ //获取老菜谱数据 if(!empty($val['_source']['smalltext'])){ $description=$val['_source']['smalltext']; }else{ $description=""; } } $description=rtrim($description,"\n"); //背后的故事 $bz_recipe['id'] = $val['_id']; $bz_recipe['smalltext'] = $description; $bz_recipe['title'] = $val['_source']['title']; $bz_recipe["img"] = $titlepic?$titlepic:'http://css.meishij.net/images/noimg.gif'; $bz_recipe["zhuliao"] = $val['_source']['zhuliao']; $bz_recipe['url'] = "//www.bujia24.com/zuofa/".$val['_source']['title_pinyin'].".html"; //作者信息 if(!empty($val['_source']['writer_id'])){ $to_user_id = $val['_source']['writer_id']; $user = user::get_by_id_fc($to_user_id); $bz_recipe['user_name']=$user['user_name']; $bz_recipe['user_id']=$user['user_id']; $bz_recipe['avatar_url']=user_profile::st($user[user::PHOTO],false,false,$user[user::GENDER]); }else{ $bz_recipe['user_name']="美食杰"; $bz_recipe['user_id']="0"; $bz_recipe['avatar_url']="http://s1.c.meishij.net/n/images/msjavatar.png"; } $items[] = $bz_recipe; } $result = $items; //搭配宜忌 $news_yuanliao = array(); if(!empty($words)){ $news_yuanliao = news_yuanliao::get_one_by_con(array(news_yuanliao::TITLE => $words)); } $collocation = array(); if($news_yuanliao){ if(!empty($news_yuanliao[news_yuanliao::FOOD_TABOO])){ $food_taboo = $news_yuanliao[news_yuanliao::FOOD_TABOO]; $food_taboo = str_replace(array("\n",':'),array(';',':'),$food_taboo); $tmp1 = explode(';',$food_taboo); $show_num = 0; foreach ($tmp1 as $tmp2){ if($tmp2){ $tmp3 = explode(':',$tmp2); if(count($tmp3) == 3){ $news_yuanliao_tmp3 = news_yuanliao::get_by_id($tmp3[0]); if(!empty($news_yuanliao_tmp3)){ if($show_num>=4){ continue; } $title_pinyin = character2pinyin::c2_all($news_yuanliao_tmp3[news_yuanliao::TITLE]); $jinji_url = '/wenda/'.$pinyin."-".$title_pinyin; if($tmp3[1] == 'yi'){ $tag = 'good'; $href = _web_path($jinji_url."-1.html",'w'); }else{ $tag = 'bad'; $href = _web_path($jinji_url."-2.html",'w'); } $collocation[$tag][] = array( 'shicai2_title' => $news_yuanliao_tmp3[news_yuanliao::TITLE], 'img' => $news_yuanliao_tmp3[news_yuanliao::TITLEPIC], 'desc' => ms_util::get_clean_text($tmp3[2]), 'href' => $href, ); $show_num++; } } } } } } //阅读推荐 include_dev_util('seo_common.php'); $read_recommend_list = seo_common::read_recommend_list($words,10); //热门标签 include_dev_model('meishij/recipe_seo_search_word.php'); $hot_recommend_list = recipe_seo_search_word::hot_recommend_list_pc(); //菜名列表 tdk $seo_tdk = ""; if($type==2){ $seo_tdk = recipe_seo_tdk::get_class_tdk($is_seo_tdk_type,$words,$page); } $tj_info = array(); $wordsinfo = array(); $videos_percent = array(); //百分比 $is_video = false; //视频标识 if($url_path=='caipu'){ //获取视频数据 $videos = videos::get_videos_by_title($words); if(empty($videos)){ //截取第一个菜谱判断是否为视频菜谱 $frist_recipe = array_slice($rel_newses,0,1); if(!empty($frist_recipe)){ //获取user_recipe 数据 $news = phome_ecms_news::get_by_id($frist_recipe[0]['id']); if(!empty($news['user_recipe_id'])){ $user_recipe = user_recipe::get_by_id($news['user_recipe_id']); if(!empty($user_recipe)&&$user_recipe['vendor_video']!=''){ //视频标识 $is_video = true; } } } }else{ $is_video = true; } //获取百分比数据 $videos_percent = recipe_seo_search_word_extr::get_words_extro_by_title($words); //获取菜谱词菜谱数量 $wordsinfo = recipe_seo_search_word::get_words_by_title($words); //获取关联菜谱20篇数据 $tj_info['new'] = m_search::hot_recommend_recipe($words,$rel_newses); if(!empty($tj_info['new'])){ foreach($tj_info['new'] as $key => $value){ $news = phome_ecms_news::get_by_id($value['id']); if(!empty($news)){ $summary = ''; $tmp_li = array(); if(!empty($news[phome_ecms_news::STEP_NUMS])){ $tmp_li[] = $news[phome_ecms_news::STEP_NUMS].'步'; } if(!empty($news[phome_ecms_news::MAKE_TIME])){ $tmp_li[] = "大概".str_replace('<','',ms_util::$make_time_ar[$news[phome_ecms_news::MAKE_TIME]]); } if(!empty($tmp_li)){ $summary = '