IndexTank - Faceted Search on Nested Attributes
I have implemented full text search on my Rails 3 app using IndexTank and the Tanker gem.  I am now trying to add faceted search but i'm having problems trying to index facets for nested attributes.

I have two models Post and Category. I do all my indexing on the post model below.

    class Post < ActiveRecord::Base
      
      # include the Tanker module for search using IndexTank
      include Tanker
      
      # Relationships
      has_many :post_categories
      has_many :categories, :through => :post_categories
    
      
      tankit index do
        indexes :title
        indexes :description
        indexes :category_names do
          categories.map {|category| category.name }
        end
        
        # Set values for faceted search
        category :category do
            categories.map {|category| category.name }
        end
        
        # Variables available in scoring function
        
      end
      
      # define the callbacks to update or delete the index upon saving and deleting records
      after_save :update_tank_indexes
      after_destroy :delete_tank_indexes

I want facets to contain all the nested categories for a post. The way i'm doing it now puts categories into an array which indextank (or tanker) converts into a single string when I try to perform a query. What I want is for each category to be separate so I can pass a single category name into the search like below. This only returns results if there is an exact match.

    @posts = Post.search_tank( "query", :category_filters => {'category' => params[:category])

The other issue I have is that my categories are nested using the 'ancestry' gem so I would like to be able to be able to 'drill down' the list of categories like this http://wiki.apache.org/solr/HierarchicalFaceting. Though I can't find anything that indicates how to do this with indextank/tanker 

Any suggestions would be appreciated.
IndexTank - Faceted Search on Nested Attributes
===

I have implemented full text search on my Rails 3 app using IndexTank and the Tanker gem.  I am now trying to add faceted search but i'm having problems trying to index facets for nested attributes.

I have two models Post and Category. I do all my indexing on the post model below.

    class Post < ActiveRecord::Base
      
      # include the Tanker module for search using IndexTank
      include Tanker
      
      # Relationships
      has_many :post_categories
      has_many :categories, :through => :post_categories
    
      
      tankit index do
        indexes :title
        indexes :description
        indexes :category_names do
          categories.map {|category| category.name }
        end
        
        # Set values for faceted search
        category :category do
            categories.map {|category| category.name }
        end
        
        # Variables available in scoring function
        
      end
      
      # define the callbacks to update or delete the index upon saving and deleting records
      after_save :update_tank_indexes
      after_destroy :delete_tank_indexes

I want facets to contain all the nested categories for a post. The way i'm doing it now puts categories into an array which indextank (or tanker) converts into a single string when I try to perform a query. What I want is for each category to be separate so I can pass a single category name into the search like below. This only returns results if there is an exact match.

    @posts = Post.search_tank( "query", :category_filters => {'category' => params[:category])

The other issue I have is that my categories are nested using the 'ancestry' gem so I would like to be able to be able to 'drill down' the list of categories like this http://wiki.apache.org/solr/HierarchicalFaceting. Though I can't find anything that indicates how to do this with indextank/tanker 

Any suggestions would be appreciated.