Apache Pig:来自网络日志的额外查询参数 [英] Apache Pig: Extra query parameters from web log
本文介绍了Apache Pig:来自网络日志的额外查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在分析 AWS CloudFront 访问日志.
I am working on analyzing AWS CloudFront access logs.
我有加载文件行的代码
raw_logs2 =LOAD 'file:///home/ec2-user/ENWRZAC68E00M.2011-02-28-18.72jA8eGh'
USING PigStorage('\t')
AS (
date: chararray, time: chararray, x_edge_location: chararray, sc_bytes: int,
c_ip: chararray, cs_method: chararray, cs_host: chararray, cs_uri_stem: chararray,
sc_status: chararray, cs_referer: chararray, cs_user_agent:chararray, cs_uri_query: chararray
);
现在我正在尝试解析查询字符串参数(名称/值对):
Now I am trying to parse the query string parameters(name/value pairs):
p=searchresults&s=homesforsale&gad=&gci=FOUNTAIN%2520VALLEY&gst=CA&gzi=&k=fountainvalleyca&ts=1298918206&
如何在我的 raw_logs2 表中为查询字符串中的 p、s 和 gci 的值添加额外的列?
How can I add an additional columns to my raw_logs2 table for the values of p,s and gci in the query string?
推荐答案
一种快速的方法是使用 REGEX_EXTRACT_ALL:
One quick way to do it is to use REGEX_EXTRACT_ALL:
raw_logs =
GENERATE
*,
FLATTEN(REGEX_EXTRACT_ALL(cs_uri_query, 'p=(.+?)&s=(.+?)&.+?gci=(.+?)&.+?'))
AS (p:CHARARRAY, s:CHARARRAY, gci:CHARARRAY);`
这篇关于Apache Pig:来自网络日志的额外查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文