Return-Path: Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: (qmail 47082 invoked from network); 4 Apr 2011 02:37:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Apr 2011 02:37:50 -0000 Received: (qmail 44559 invoked by uid 500); 4 Apr 2011 02:37:47 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 44533 invoked by uid 500); 4 Apr 2011 02:37:47 -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 44525 invoked by uid 99); 4 Apr 2011 02:37:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2011 02:37:47 +0000 X-ASF-Spam-Status: No, hits=4.0 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of erickerickson@gmail.com designates 209.85.216.169 as permitted sender) Received: from [209.85.216.169] (HELO mail-qy0-f169.google.com) (209.85.216.169) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2011 02:37:40 +0000 Received: by qyk2 with SMTP id 2so890336qyk.14 for ; Sun, 03 Apr 2011 19:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=WhK6WDl5FJMytOvb8oawfARtTu4dQ9pt60S5/1y96iM=; b=ZYRNt2xhWNvELJqWKUotUukBA7UzLT5woYs8RdCoUD8qgEThta7eQWyviKhypXBiyq 9kg1j50CA/36gwivrxm/MBQ+vFU5n6lj+OFW55VAMRqNqXIsRKYQflrQXpSJbAjdcp4i cvcchYmUkLEonOh6zGKoqTtDchKng1yzbyj2Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=WKwJJ8OaGg2hqiRtMAvzoZ51liUb/y/PtXYjHciafqeISWTI1XKQogz2Rxqua/sejg 1UuxsSRsEUF6N9JsRw7O3/4/1PE4D+0e/mFqpzx1HEVL2OzOKWkz6mpi+tHLmSvd0Nq5 M+ivr6a+2PyG780wsymbyOZk238jFfkcT+3UA= MIME-Version: 1.0 Received: by 10.229.111.82 with SMTP id r18mr5337464qcp.124.1301884639309; Sun, 03 Apr 2011 19:37:19 -0700 (PDT) Received: by 10.229.72.8 with HTTP; Sun, 3 Apr 2011 19:37:19 -0700 (PDT) In-Reply-To: References: Date: Sun, 3 Apr 2011 22:37:19 -0400 Message-ID: Subject: Re: Faceting on multivalued field From: Erick Erickson To: solr-user@lucene.apache.org Content-Type: multipart/alternative; boundary=0023544706f876f17004a00ea320 --0023544706f876f17004a00ea320 Content-Type: text/plain; charset=ISO-8859-1 Why not count them on the way in and just store that number along with the original e-mail? Best Erick On Sun, Apr 3, 2011 at 10:10 PM, Kaushik Chakraborty wrote: > Ok. My expectation was since "comment_post_id" is a MultiValued field hence > it would appear multiple times (i.e. for each comment). And hence when I > would facet with that field it would also give me the count of those many > documents where comment_post_id appears. > > My requirement is getting total for every document i.e. finding number of > comments per post in the whole corpus. To explain it more clearly, I'm > getting a result xml something like this > > 46 > Hello World > 20 > > 9 > 10 > > > 19 > 2 > > > 46 > 46 > > > Hello - from World > Hi > > > > > *1* > > I need the count to be 2 as the post 46 has 2 comments. > > What other way can I approach? > > Thanks, > Kaushik > > > On Mon, Apr 4, 2011 at 4:29 AM, Erick Erickson >wrote: > > > Hmmm, I think you're misunderstanding faceting. It's counting the > > number of documents that have a particular value. So if you're > > faceting on "comment_post_id", there is one and only one document > > with that value (assuming that the comment_post_ids are unique). > > Which is what's being reported.... This will be quite expensive on a > > large corpus, BTW. > > > > Is your task to show the totals for *every* document in your corpus or > > just the ones in a display page? Because if the latter, your app could > > just count up the number of elements in the XML returned for the > > multiValued comments field. > > > > If that's not relevant, could you explain a bit more why you need this > > count? > > > > Best > > Erick > > > > On Sun, Apr 3, 2011 at 2:31 PM, Kaushik Chakraborty > >wrote: > > > > > Hi, > > > > > > My index contains a root entity "Post" and a child entity "Comments". > > Each > > > post can have multiple comments. data-config.xml: > > > > > > > > > > > dataSource="jdbc" query=""> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The schema has all columns of "comment" entity as "MultiValued" fields > > and > > > all fields are indexed & stored. My requirement is to count the number > of > > > comments for each post. Approach I'm taking is to query on "*:*" and > > > faceting the result on "comment_post_id" so that it gives the count of > > > comment occurred for that post. > > > > > > But I'm getting incorrect result e.g. if a post has 2 comments, the > > > multivalued fields are populated alright but the facet count is coming > as > > 1 > > > (for that post_id). What else do I need to do? > > > > > > > > > Thanks, > > > Kaushik > > > > > > --0023544706f876f17004a00ea320--