Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A617118E0A for ; Fri, 12 Jun 2015 14:31:19 +0000 (UTC) Received: (qmail 63726 invoked by uid 500); 12 Jun 2015 14:31:15 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 63660 invoked by uid 500); 12 Jun 2015 14:31:15 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 63647 invoked by uid 99); 12 Jun 2015 14:31:14 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Jun 2015 14:31:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 67E321A54FF for ; Fri, 12 Jun 2015 14:31:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.487 X-Spam-Level: *** X-Spam-Status: No, score=3.487 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, NML_ADSP_CUSTOM_MED=1.2, SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 94R_3uJwKvCH for ; Fri, 12 Jun 2015 14:31:02 +0000 (UTC) Received: from mwork.nabble.com (mwork.nabble.com [162.253.133.43]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 8B3CC429A8 for ; Fri, 12 Jun 2015 14:31:02 +0000 (UTC) Received: from mben.nabble.com (unknown [162.253.133.72]) by mwork.nabble.com (Postfix) with ESMTP id A4E8720B8E39 for ; Fri, 12 Jun 2015 07:30:32 -0700 (PDT) Date: Fri, 12 Jun 2015 07:30:32 -0700 (MST) From: kingofhypocrites To: solr-user@lucene.apache.org Message-ID: <1434119432169-4211402.post@n3.nabble.com> Subject: Division with Stats Component when Grouping in Solr MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I am migrating a database from SQL Server to Cassandra. Currently I have a setup as follows: - Log data in Cassandra - Summarize data in Spark and put into Cassandra summary tables - Query data in Solr Everything fits beautifully until I need to do stats on groups. I am hoping to get this to work with Solr so I can stick to one database, but I am not sure it's possible. If I had it in SQL Server, I could do it like so: SELECT site_id, keyword, SUM(visits) as visits, CONVERT(DECIMAL(13, 3), SUM(bounces)) / SUM(visits) as bounce_rate, SUM(pageviews) as pageviews, CONVERT(DECIMAL(13, 3), SUM(pageviews)) / SUM(visits) as avg_pages_per_visit FROM report_all_keywords_daily WHERE site_id = 55 AND date_key >= '20150606' AND date_key <= '20150608' GROUP BY site_id, keyword ORDER BY visits DESC Now I need to replicate this in Solr. The closest I could get to this is by using the Stats component and then using field collapsing. group=true&group.field=keyword&stats=true&stats.field=visits&stats.facet=keyword And here are some results I get back: http://pastebin.com/raw.php?i=Fxhe2RA0 However, I need to do able to divide certain metrics. I tried including functions in the stats.field such as div(sum(bounce_rate), (sum(visits)) but it doesn't recognize the functions. Also it seems to ignoring the paging for the stats results and returns all groups regardless. Ultimately I'd like something like this which is what I would get in SQL: Is this possible or do I have to give up on the prospect of using Solr? I have to query this data dynamically so I can't pre-summarize all of it. To clarify I having the following two problems: - Paging is ignored for stats data - I can't figure out how to divide two stats together to get a third stat. Note: In some cases I would need to be able to sort on this combined stat -- View this message in context: http://lucene.472066.n3.nabble.com/Division-with-Stats-Component-when-Grouping-in-Solr-tp4211402.html Sent from the Solr - User mailing list archive at Nabble.com.