欢迎投稿

今日深度:

hive初试,

hive初试,


1:搭建hadoop和hive,mysql的环境,过程截图。

 

2:利用上节课的数据,建表并导入数据。

3:最热门的查询词排行 top10
4:用户查询排行 top10
5:搜索结果排名第1,但是点击次序排在第2的数据有多少?

 

2:利用上节课的数据,建表并导入数据。

数据格式说明:
访问时间\t用户ID\t[查询词]\t该URL在返回结果中的排名\t用户点击的顺序号\t用户点击的URL
其中,用户ID是根据用户使用浏览器访问搜索引擎时的Cookie信息自动赋值,即同一次使用浏览器输入的不同查询对应同一个用户ID。

CREATE EXTERNAL TABLE sg_table(
  last_update string,
  col_a string,
  col_b string,
  col_c string,
  col_d string,
  col_e string,
  col_f string,
  col_g string,
  col_h string,
  col_i string,
  col_j string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
location '/hadoop/dw/sogoutest';
hadoop put sogout.txt /hadoop/dw/sogoutest

 

3:最热门的查询词排行 top10

select col_b ,count(col_b) as top10 from sg_table group by col_b  order by top10  desc limit 10 ;


4:用户查询排行 top10

select col_a ,count(col_a) as top10 from sg_table group by col_a  order by top10  desc limit 10 ;


5:搜索结果排名第1,但是点击次序排在第2的数据有多少?

select col_b , count(col_b) as top1  from sg_table where col_i=2 group by col_b order by top1 desc limit 1;

www.htsjk.Com true http://www.htsjk.com/hive/40727.html NewsArticle hive初试, 1:搭建hadoop和hive,mysql的环境,过程截图。   2:利用上节课的数据,建表并导入数据。 3:最热门的查询词排行 top10 4:用户查询排行 top10 5:搜索结果排名第1,但是点击次...
相关文章
    暂无相关文章
评论暂时关闭