Return-Path: X-Original-To: apmail-asterixdb-dev-archive@minotaur.apache.org Delivered-To: apmail-asterixdb-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D78118552 for ; Wed, 9 Dec 2015 18:46:18 +0000 (UTC) Received: (qmail 6872 invoked by uid 500); 9 Dec 2015 18:46:18 -0000 Delivered-To: apmail-asterixdb-dev-archive@asterixdb.apache.org Received: (qmail 6821 invoked by uid 500); 9 Dec 2015 18:46:18 -0000 Mailing-List: contact dev-help@asterixdb.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.incubator.apache.org Delivered-To: mailing list dev@asterixdb.incubator.apache.org Received: (qmail 6809 invoked by uid 99); 9 Dec 2015 18:46:17 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Dec 2015 18:46:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 4A6E3C7211 for ; Wed, 9 Dec 2015 18:46:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.879 X-Spam-Level: ** X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id IPyaCPhBdheJ for ; Wed, 9 Dec 2015 18:46:16 +0000 (UTC) Received: from mail-vk0-f49.google.com (mail-vk0-f49.google.com [209.85.213.49]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id A988520599 for ; Wed, 9 Dec 2015 18:46:15 +0000 (UTC) Received: by vkay187 with SMTP id y187so60991048vka.3 for ; Wed, 09 Dec 2015 10:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=zzivAUst1X6PzFmK+ftxDDyZg8YVhDcpEMPmsgxvam0=; b=ZS38FcsijsgoNzOOBSK+KZ+Kek6V/I2s2iYgzMQsk59bdvL+rfcRXh9ScBN3ytz7BV kFYCtkFlzEWBbSpxaI5AKemjaMbCFhWsBWifqveOCR5T5G2hqfnK6bJRbenRU5N0E1Dp jwWGRDTPKJID1laMeJO9qKKr8R8coL0ZRx7BIbMeUs874aKskH0dS5TZ2xoODV8BRPxI h1LfYbuxArtajdjbJ1jQBJ+I/tVHlRXvkrpyjeEkQa0MQ1yptFVH+tY7HzJvaZh2IOMs zGS/GqS8/+tJZsxEWdnWMH+r3StOHuiKYyAfXIwirE6ziq9VNTGNLhmZxE2crX9Bt6jm Tdgw== MIME-Version: 1.0 X-Received: by 10.129.153.198 with SMTP id q189mr1524551ywg.337.1449686474133; Wed, 09 Dec 2015 10:41:14 -0800 (PST) Received: by 10.37.92.132 with HTTP; Wed, 9 Dec 2015 10:41:14 -0800 (PST) In-Reply-To: References: Date: Wed, 9 Dec 2015 10:41:14 -0800 Message-ID: Subject: Re: How to calculate the word count in AQL? From: Yingyi Bu To: dev@asterixdb.incubator.apache.org Content-Type: multipart/alternative; boundary=94eb2c0b7316539c1905267b6fec --94eb2c0b7316539c1905267b6fec Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This probably is the query you want: for $ts in $hashtags for $t in $ts group by $tag:=3D$t with $t return {"g": $tag, count($t)} On Wed, Dec 9, 2015 at 10:34 AM, Jianfeng Jia wrote: > Hi devs, > > Here is my use case, each tweets has a set of hashtags. Here is the > hashtags example for the first five tweets: > [ {{ "Samibeigi" }}, {{ "LeadwithGiants" }}, {{ "MountainView", > "Healthcare", "Job" }}, {{ "SanFrancisco", "job", "NettempsJobs", "IT", > "Hiring", "CareerArc" }}, {{ "BeGreat" }} ] > I want to calculate the most frequent hashtag in all tweets. > > I could generate a internal group count as following > > let $inner :=3D for $x in $hashtags > return > for $xx in $x > group by $xx with $xx > return { "g": $xx[0], "c": count($xx)} > > It will return a list of list, > [ { "g": "Samibeigi", "c": 1 } ] > [ { "g": "LeadwithGiants", "c": 1 } ] > [ { "g": "Healthcare", "c": 1 }, { "g": "Job", "c": 1 }, { "g": > "MountainView", "c": 1 } ] > [ { "g": "CareerArc", "c": 1 }, { "g": "Hiring", "c": 1 }, { "g": "IT", > "c": 1 }, { "g": "NettempsJobs", "c": 1 }, { "g": "SanFrancisco", "c": 1 = }, > { "g": "job", "c": 1 } ] > [ { "g": "BeGreat", "c": 1 } ] > > I would expect to add a flatten function to the list which will give me a > list of record, then I can groupby the =E2=80=9Cg". Do we have such AQL f= unctions? > Thank you. > > Best, > > Jianfeng Jia > PhD Candidate of Computer Science > University of California, Irvine > > --94eb2c0b7316539c1905267b6fec--