Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Facets
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom Davies  
View profile  
 More options May 13 2008, 9:16 am
From: Tom Davies <atomgi...@gmail.com>
Date: Tue, 13 May 2008 06:16:33 -0700 (PDT)
Local: Tues, May 13 2008 9:16 am
Subject: Facets
I just recently switched to ThinkingSphinx from Ultrasphinx (and
before that acts_as_sphinx).  Ultrasphinx worked great but had just a
couple issues that ThinkingSphinx resolves.  Most notably the multi-
valued field support.  One feature of Ultrasphinx I ported over to
ThinkingSphinx is the ability to generate facets for your attributes.
It requires an additional sphinx call per attribute but in my
experience it is very fast.

I am posting this patch to the group in hopes that this could be
rolled into ThinkingSphinx or at least be useful for others.  I am
currently loading this using a Rails initializer.  Comments and
improvements are welcome:.

Here is the code for facets:

require 'thinking_sphinx'
module ThinkingSphinx
  class Search
    class << self
      # Add facet support
      def facets(query, attrs, options={})
        options.merge!({:group_function => :attr, :group_clauses =>
"@count desc"})
        attrs = [attrs] unless attrs.is_a? Array
        attr_facets = {}
        attrs.each do |attr|
          options[:group_by]=attr
          results, client = search_results(query, options)
          facets = {}
          results[:matches].each {|e| facets[e[:attributes]
['@groupby']]=e[:attributes]['@count']}
          attr_facets[attr] = facets
        end
        attr_facets
      end
    end
  end
end


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pat Allan  
View profile  
 More options May 13 2008, 9:21 am
From: Pat Allan <p...@freelancing-gods.com>
Date: Tue, 13 May 2008 23:21:49 +1000
Local: Tues, May 13 2008 9:21 am
Subject: Re: [ts] Facets
Hi Tom

Thanks for that code - I've had a couple of other people request the  
facets feature. When I'm more awake I'll actually pay attention to the  
code and try to wrap it in to trunk.

It's also worth knowing that Patrick Lenz has at least begun adding  
facets as well - his fork on github is:
http://github.com/scoop/thinking-sphinx/tree/master

Whether it's complete or not, or similar to yours, I've no idea.  
Again, something to analyse in the morning.

Thanks again

--
Pat
e: p...@freelancing-gods.com    || m: 0413 273 337
w: http://freelancing-gods.com || p: 03 9386 0928
discworld: http://ausdwcon.org || skype: patallan

On 13/05/2008, at 11:16 PM, Tom Davies wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Davies  
View profile  
 More options May 13 2008, 9:41 am
From: Tom Davies <atomgi...@gmail.com>
Date: Tue, 13 May 2008 06:41:23 -0700 (PDT)
Local: Tues, May 13 2008 9:41 am
Subject: Re: Facets
Great.  I looked at the other code and it looks pretty similar.

One difference is that my function supports passing in multiple
attributes to facet:

> ThinkingSphinx::Search.facets('things', ['color', 'size'])

{'color' => {1 => 88, 2 => 12}, 'size' => {1 => 33, 4 => 66}}

Versus:

> ThinkingSphinx::Search.faceted_search('things', :group_by => 'color')

{1 => 88, 2 => 12}

> ThinkingSphinx::Search.faceted_search('things', :group_by => 'size')

{1 => 33, 4 => 66}

Also, it looks like Patrick's code supports faceting by class?  Not
100% sure on how that is used.

Tom

On May 13, 9:21 am, Pat Allan <p...@freelancing-gods.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google