我在ES中有三个日志,如
{"@timestamp":"2022-07-19T11:24:16.274073+05:30","log":{"level":200,"logger":"production","message":"BUY_ITEM1","context":{"user_id":31312},"datetime":"2022-07-19T11:24:16.274073+05:30","extra":{"ip":"127.0.0.1"}}}
{"@timestamp":"2022-07-19T11:24:16.274073+05:30","log":{"level":200,"logger":"production","message":"BUY_ITEM2","context":{"user_id":31312},"datetime":"2022-07-19T11:24:16.274073+05:30","extra":{"ip":"127.0.0.1"}}}
{"@timestamp":"2022-07-19T11:24:16.274073+05:30","log":{"level":200,"logger":"production","message":"CLICK_ITEM3","context":{"user_id":31312},"datetime":"2022-07-19T11:24:16.274073+05:30","extra":{"ip":"127.0.0.1"}}}
我可以通过在Kibana的KQL中查询log.message: "BUY_ITEM1"
来获得购买Item1
的用户。
如何获取同时具有BUY_ITEM1
和BUY_ITEM2
的用户ID?
1条答案
按热度按时间pjngdqdw1#
Tldr;
存在于
SQL
中的Join
查询在Elasticsearch
中是不可能的,它们是(非常有限的)。您需要解决此问题。
解决方法
您可以对他们购买的所有产品的
user_id
执行aggregation。这将给予以下结果