作者 邓超

es

@@ -218,9 +218,25 @@ class MailListV2Es extends Base { @@ -218,9 +218,25 @@ class MailListV2Es extends Base {
218 $query['bool']['must'][] = $this->assignSql('收件箱'); 218 $query['bool']['must'][] = $this->assignSql('收件箱');
219 } 219 }
220 220
221 - logs('请求es前'); 221 + if($folder=='收件箱'&&empty($is_auto_inbox)){
  222 + $from_not_in_like = app()->request('from_not_in_like');
  223 + if ($from_not_in_like) {
  224 + $from_not_in_like = is_array($from_not_in_like) ? $from_not_in_like : [$from_not_in_like];
  225 + $notinquery = [];
  226 + foreach ($from_not_in_like as $k => $sub) {
  227 + if($sub){
  228 + $notinquery[] = ['match'=>['from.email'=>$sub]];
  229 + }
  230 + }
  231 + if($notinquery){
  232 + $query['bool']['must_not'] = $notinquery;
  233 + }
  234 + }
  235 + }
  236 +
  237 +
222 $result = $this->es->search(['query'=>$query],($page-1) * $limit,$limit,['udate'=>"desc"]); 238 $result = $this->es->search(['query'=>$query],($page-1) * $limit,$limit,['udate'=>"desc"]);
223 - logs('请求es后'); 239 +
224 240
225 $total = $result['hits']['total']['value']??0; 241 $total = $result['hits']['total']['value']??0;
226 $lists = $result['hits']['hits']??[]; 242 $lists = $result['hits']['hits']??[];
@@ -441,12 +457,10 @@ class MailListV2Es extends Base { @@ -441,12 +457,10 @@ class MailListV2Es extends Base {
441 },$udate); 457 },$udate);
442 // 时间范围搜索 458 // 时间范围搜索
443 $body['query']['bool']['must'][] = [ 459 $body['query']['bool']['must'][] = [
444 - 'query' => [  
445 - 'range' => [  
446 - 'udate' => [  
447 - 'gte' => $udate[0], // 大于等于开始日期  
448 - 'lte' => $udate[1] // 小于等于结束日期  
449 - ] 460 + 'range' => [
  461 + 'udate' => [
  462 + 'gte' => $udate[0], // 大于等于开始日期
  463 + 'lte' => $udate[1] // 小于等于结束日期
450 ] 464 ]
451 ] 465 ]
452 ]; 466 ];
@@ -522,6 +536,23 @@ class MailListV2Es extends Base { @@ -522,6 +536,23 @@ class MailListV2Es extends Base {
522 private function countMail($body,$folder,$seen=null){ 536 private function countMail($body,$folder,$seen=null){
523 if($folder == '收件箱'){ 537 if($folder == '收件箱'){
524 $body['query']['bool']['must'][] = ['term'=>['is_auto'=>0]]; 538 $body['query']['bool']['must'][] = ['term'=>['is_auto'=>0]];
  539 +
  540 +
  541 + $from_not_in_like = app()->request('from_not_in_like');
  542 + if ($from_not_in_like) {
  543 + $from_not_in_like = is_array($from_not_in_like) ? $from_not_in_like : [$from_not_in_like];
  544 + $notinquery = [];
  545 + foreach ($from_not_in_like as $k => $sub) {
  546 + if($sub){
  547 + $notinquery[] = ['match'=>['from.email'=>$sub]];
  548 + }
  549 + }
  550 + if($notinquery){
  551 + $body['query']['bool']['must_not'] = $notinquery;
  552 + }
  553 + }
  554 +
  555 +
525 } 556 }
526 if($seen!==null){ 557 if($seen!==null){
527 $body['query']['bool']['must'][] = ['term'=>['seen'=>$seen]]; 558 $body['query']['bool']['must'][] = ['term'=>['seen'=>$seen]];