一、微博分析
http://playbigdata.ruc.edu.cn/weibonow_v3
(需注册后申请权限)
三、时事探针
时事探针主要搜索主流媒体网站中的新闻全文或者匹配的句子
全文接口:
示例接口如下:
句子接口:
示例接口如下:
query: 待查询的查询词,可以使用solr中查询的语法。例如查询2019年9月3日至今的包含中国人民大学的文档,使用下面查询:
中国人民大学%20AND%20Time:%20[2019-09-03T00:00:00Z%20TO%20*]
start:从第几个结果,默认是1
num:返回多少个结果,建议小于100,默认是10。在取结果时,建议分页取,每次设置一个不同的start,num设置为每页结果数。
highlighting:是否高亮显示文档中匹配的查询词,true为标亮关键词,false不标亮;
compact:为true时返回文档的URL,Title,Time,Text等简单字段,为false时还会同时返回文档中抽取的实体等其他字段信息;默认为true
返回格式:
[DataContract]
public class SearchResults
{
public int TotalCount { get; set; }
public int Start { get; set; }
public ICollection<SolrDocRecordView> Documents { get; set; }
}
public class SolrDocRecord
{
public string Id { get; set; }
public string DocId { get; set; }
public string Url { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public string Html { get; set; }
public string[] Images { get; set; }
public string Breaked { get; set; }
public DateTime Time { get; set; }
public int Opinion { get; set; }
public string Date { get; set; }
public string[] Word { get; set; }
public string[] Nugget { get; set; }
public string[] Topic { get; set; }
public IDictionary<string, ICollection<string>> Entity { get; set; }
public IDictionary<string, ICollection<string>> PntData { get; set; }
public IDictionary<string, ICollection<string>> OWord { get; set; }
public IDictionary<string, string> DataS { get; set; }
public IDictionary<string, ICollection<string>> DataM { get; set; }
public IDictionary<string, ICollection<string>> DataStored { get; set; }
public IDictionary<string, int> Meta { get; set; }
public double Score { get; set; }
public string DisplayUrl { get; set; }
public string Snippet { get; set; }
public string TimeStr { get; set; }
}
示例返回文档:
{"Documents":[
{
"Breaked":null,
"DataM":null,
"DataS":[{"Key":"Domain","Value":"sohu.com"}],
"DataStored":null,"Date":"2019-09-06",
"DocId":"0000000030983314",
"Entity":[{"Key":"Location","Value":["天柱山","安徽省","黄山"]},{"Key":"Person","Value":["齐云山","余秋雨","白居易","李白","白马","卓文君","司马相如","田野"]},{"Key":"Orgnization","Value":["全国达人玩透天柱山采风团","合肥客运南站","国家新闻出版总署","国家旅游局","空中茶庄-三祖寺-十里潜河","山谷流泉文化园茶艺文化馆"]}],"Html":null,"Id":"0000000030983314","Images":null,"Meta":null,"Nugget":["东方最美花岗岩","寂寞天柱山","天柱一峰擎日月,洞门天仞锁云雷","奇峰出奇云,秀水含秀气","乡愁","皖菜","八戒念经,有口无心","白马潭","小吏港","焦吏港","孔雀东南飞","卓文君与司马相如","天仙文化",
"Text":"天柱归来不看峰,领略北纬30°地带天柱山的雄奇壮丽\u000a前言\u000a安徽省有很多名山,如闻名世界的黄山和九华山,让人耳熟能详的齐云山,还有一个以“东方最美花岗岩”地貌闻名于世的天柱山。\u000a天柱山拥有奇峰、怪石、幽洞、峡谷等自然景观,尤以崩塌堆垒型奇景享誉世界。这次有幸和全国达人玩透天柱山采风团一起游玩了名不虚传的天柱山。最早了解天柱山是阅读余秋雨的散文《寂寞天柱山》得知的,历代大文豪、大诗人都曾游历过,对它情有独钟,白居易诗云:“天柱一峰擎日月,洞门天仞锁云雷”;李白诗云:“奇峰出奇云,秀水含秀气”。\u000a天柱山坐落于大别山与长江中下游平原交汇处,今安徽省安庆市潜山市境内。天柱峰(海拔1488.4米)、飞来峰、五指峰为全国同名峰之冠;号称花岗岩洞第一秘府的神秘谷,结构奇特,谷洞相连,境状递次变幻,令人意趣横生;海拔1100米的炼丹湖为全国第三大高山平湖,九井河瀑布跌落成群,美仑美奂。..... \u000a",
"Time":"\/Date(1567740063403)\/",
"Title":"天柱归来不看峰,领略北纬30°地带天柱山的雄奇壮丽",
"Topic":null,
"Url":"http:\/\/www.sohu.com\/a\/339046435_134224?spm=smpc.news-home.travel-news.4.1567710367026mPWa9tY",
"Word":null,
"DisplayUrl":"http:\/\/www.sohu.com\/a\/339046435_134224?spm=smpc.news-home.travel-news.4.1567710367026mPWa9tY",
"Score":0.15793434,
"Snippet":null,
"TimeStr":"2019-09-06 03:21:03"
},
{
"Breaked":null,"DataM":null,"DataS":[{"Key":"Domain","Value":"ce.cn"}],"DataStored":null,"Date":"2019-09-06","DocId":"0000000030983069","Entity":[{"Key":"Location","Value":["中国","河南","洛阳","河南省","洛阳市","成都","湖南省","湘西州","十八洞村","长江三角洲"]},{"Key":"Person","Value":["蔡松松","买买提江·托乎尼牙孜","汪勇","施成富","习近平","刘海全","沙利","库布其","安庆","陆福明","刘国周","王美华","刘海玲"]},{"Key":"Orgnization","Value":["世界银行","中国共产党","沪苏浙皖四地人大常委会","人大","党中央","水务和水土保持局","亿利民工联队","国家广播电视总局","大黄山国家公园","重庆市委","常委会","北京市西城区践行","西城区践行"]}],"Html":null,"Id":"0000000030983069","Images":null,"Meta":null,"Nugget":["负重前行","五项治理","治污","治脏","治违","治乱","治差",],"OWord":null,"Opinion":3,","Time":"\/Date(1567739528457)\/","Title":"国际经济","Topic":null,"Url":"http:\/\/ads.ce.cn\/c?d=ceafp&i=z421,1818807,4477,3289&k=&p=0&v=5844715&wl=&rf=http:\/\/www.ce.cn\/&u=http:\/\/www.ce.cn\/ztpd\/xwzt\/guonei\/yqq\/xjp_299088\/index.shtml","Word":null,"DisplayUrl":"http:\/\/ads.ce.cn\/c?d=ceafp&i=z421,1818807,4477,3289&k=&p=0&v=5844715&wl=&rf=http:\/\/www.ce.cn\/&u=http:\/\/www.ce.cn\/ztpd\/xwzt\/guonei\/yqq\/xjp_299088\/index.shtml","Score":0.09870896,"Snippet":null,"TimeStr":"2019-09-06 03:12:08"}
],
"Start":11,
"TotalCount":39120
}
四、微博&微信公众号搜索API
微博搜索服务ip地址和端口为183.174.229.244:1241
微信公众号文章搜索服务ip地址和端口为183.174.229.244:1242
- 微博数据一般文档格式API,返回的文档对象为基本字段,字段名具有比较好的可读性
url:http://183.174.229.244:1241/weibo/
- 微博数据原始文档格式API,返回文档的格式和solr集群schema保持一致,原样返回所有文档字段(包括NLP处理之后的字段)
url:http://183.174.229.244:1241/weibo/original/
- 微博数据bean文档格式API,将文档中同类型的动态字段进行整合成一个Map,比如DataS(字符串动态字段)、DataM(多值字符串动态字段)、Entity(实体)、OWord(情感词),作为java bean输出
url:http://183.174.229.244:1241/weibo/bean/
- 微信公众号数据一般文档格式API
url:http://183.174.229.244:1242/wechat/
- 微信公众号数据原始文档格式API
url:http://183.174.229.244:1242/wechat/original/
- 微信公众号数据bean文档格式API
url:http://183.174.229.244:1242/wechat/bean/
6个API使用相同的访问格式和API请求参数,只在返回内容和返回格式上不同
访问格式:(以curl举例查询中国,对命令行不太了解的话,可以使用Postman)
- 使用GET请求:url参数列表方式添加访问参数,适合简单参数访问,如果使用复杂参数查询,一定要对查询参数做转义处理,避免破坏参数列表结构
如:查询关键词china,使用默认排序返回前50个结果
curl -XGET http://183.174.229.244:1241/weibo?query=china&limit=50
- 使用POST请求:将访问参数写为json对象作为请求正文(HTTP body),适合复杂的参数查询或集成到查询程序(编程语言基本都有处理json的能力)中,需要进行转义的字符比GET请求少很多
如:查询关键词china,限制时间范围在2019-08-01之前,返回前50个结果
curl -XPOST -H "Content-type: application/json" http://183.174.229.244:1241/weibo -d ‘{
“query”: “china AND Time:[* TO 2019-08-01T00:00:00Z]”,
“limit”: 50
}’
API请求参数:
l query:查询字段,可选,默认为检索所有文档,使用的规则和solr一致,字段搜索采用的字段和数据集合的schema一致(微博和微信的schema不一致,具体参见http://183.174.229.244:1241/weihao_zheng/weibo-wechat-schema)。常用举例:
香港 OR 澳门 OR 台湾:使用或规则搜索默认字段(包括微博正文和被转发的原微博文本)
香港 AND 澳门 AND 台湾:使用且规则搜索默认字段
(香港 OR 澳门) AND 台湾:使用嵌套子查询,搜索默认字段中出现台湾且出现香港或澳门的文档
Text: 香港 AND Text: 澳门:使用字段搜索,搜索仅在微博正文中就包含香港和澳门的文档
Text: 香港 AND Time: [2019-08-01T00:00:00Z TO *]:使用字段搜索,查询微博时间在2019-08-01之后的文档
补充:Time在solr中使用date数据,所以行为和普通字符串不完全相同
- a) 查询使用的时间均为UTC时区,但是返回的时间已经转换为中文东8区时区
- b) 可以使用NOW、Day等solr规定的关键词简化时间的搜索,如Time: [2019-08-06T00:00:00Z TO NOW],具体参见solr文档:https://lucene.apache.org/solr/guide/8_1/working-with-dates.html
l offset:文档开始编号,可选,默认为0,表示从头开始
l limit:文档返回个数,可选,默认为10
l highlighting:是否高亮,取值为true/false,可选,默认为是
l sortField:文档排序字段,可选,默认按照时间排序,字段名称和solr的模式一致
l sortOrder:文档排序方式,取值为asc/desc,可选,,默认为降序desc
微博数据一般文档的json格式:
{
“documentCount”: number,
“start”: number,
“maxScore”: number,
“docs”: [
{
“userId”: string,
“nickname”: string,
“avatar”: string,
“text”: string,
“url”, string,
“pictures”: string,
“time”: string,
“device”: string,
“forwardCount”: number,
“commentCount”: number,
“likeCount”: number,
“reUserId”: string,
“reNickname”: string,
“reText”: string,
“reUrl”, string,
“reTime”: string,
“reDevice”: string,
“reForwardCount”: number,
“reCommentCount”: number,
“reLikeCount”: number
}, {
…
},
…
]
}
其中,string,number为数据相应类型,空值为null
re开头字段为转发微博的原微博信息,如果为null表示该微博不是来自转发,使用number的re域设置为0
微信公众号文章数据的一般文档的json格式:
{
“documentCount”: number,
“start”: number,
“maxScore”: number,
“docs”: [
{
“nickname”: string,
“title”: string,
“text”: string,
“url”, string,
“time”: string,
“readCount”: number,
“likeCount”: number,
}, {
…
},
…
]
}
目前highlight功能开启后,text只返回含有搜索词语的句子片段,不返回整篇文章。
评论列表 共 0 条评论