123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace app\controller;
- use think\facade\Log;
- use think\facade\Request;
- class EsOrganization extends CommonEsController
- {
- public function detail()
- {
- $organization = Request::param('organization') ?? '';
- if( ! $organization) {
- return $this->_json_error('参数请求有误!');
- }
- return $this->_json_succ(
- $this->organizationDetail($organization)
- );
- }
- /**
- * 机构分析详情
- */
- protected function organizationDetail($org)
- {
- $params = [
- 'index' => $this->currentLanguage() ,
- 'body' => [
- 'size' => 0,
- 'query' => [
- 'bool' => [
- 'filter' => [
- 'term' => [
- 'organization_parsed.keyword' => $org
- ]
- ]
- ]
- ] ,
- 'aggs' => [
- 'citedTotalCnt' => [
- 'sum' => [
- 'field' => 'citation_relate_count'
- ]
- ] ,
- 'docStat' => [
- 'terms' => [
- 'field' => 'year' ,
- 'order' => [
- '_key' => 'asc'
- ] ,
- 'size' => 20
- ] ,
- 'aggs' => [
- 'citedPerYearCnt' => [
- 'sum' => [
- 'field' => 'citation_relate_count'
- ]
- ]
- ]
- ] ,
- 'topKeywords' => [
- 'terms' => [
- 'field' => 'keyword_list.keyword' ,
- 'order' => [
- '_count' => 'desc'
- ],
- 'size' => 20
- ]
- ] ,
- 'topAlbum' => [
- 'terms' => [
- 'field' => 'album_list.keyword' ,
- 'order' => [
- '_count' => 'desc'
- ] ,
- 'size' => 20
- ]
- ]
- ]
- ]
- ];
- $client = $this->getEsClient();
- $result = $client->search($params);
- $newCitedTrend = [];
- $citedTrend = $result['aggregations']['docStat']['buckets'];
- foreach($citedTrend as $key => $value) {
- $newCitedTrend[$key]['key'] = $value['key'];
- $newCitedTrend[$key]['doc_count'] = $value['citedPerYearCnt']['value'];
- }
- $organizationDetail = [
- 'achievement_num' => $result['hits']['total'] ,
- 'citation_frequency' => $result['aggregations']['citedTotalCnt']['value'] ,
- 'post_trend' => $result['aggregations']['docStat']['buckets'] ,
- 'cited_trend' => $newCitedTrend ,
- 'research_topic' => $result['aggregations']['topKeywords']['buckets'] ,
- 'top_album' => $result['aggregations']['topAlbum']['buckets']
- ];
- return $organizationDetail;
- }
- }
|