画像 数据处理开发 ### 1.画像表设计 mongodb、es(表名:project_portrait) 参数名 类型 说明 buyer string 采购单位 area string 省份 city string 城市 class string 领域行业:情报一级分类 business_type string 客户行业:政府机构、教育单位等(根据buyerclass) lasttime int64 最后更新时间,项目中最大的lasttime project_count int 项目数量 project_money float64 项目金额 -- class,对应 tag_topinformation 的值,目前只有物业一个,后面要添加四个领域标签,一共就是5个。 要依据每个标签,还有采购单位类型 ### 2.开发逻辑 2.1增量 通过pici每日获取一次项目增量,从项目增量中取出buyer进行画像表数据更新或新增 2.2存量 需求是采购单位搜索列表,所以单位范围是所有采购单位 ### 3. 请求es,获取项目金额以及项目数量; ```json { "query": { "bool": { "must": [ { "term": { "buyer": "泸州市龙马潭区人民医院" } }, { "term": { "tag_topinformation": "情报_物业" } } ] } }, "size": 1, "sort": [ { "lasttime": { "order": "desc" } } ], "aggs": { "total_price": { "sum": { "field": "sortprice" } } } } ``` 请求结果: ```json { "hits": { "total": { "value": 8461, "relation": "eq" }, "max_score": null, "hits": [] }, "aggregations": { "total_price": { "value": 1604166340.91 } } } ``` 其中hits.total 是项目总数;聚合出来的total_price 是项目金额; 这里size 设置1,根据lasttime 倒序排序,拿到的就是 lasttime 最大值的数据