Hi, first of all, I want to congratulate Pat and all the contributors
for this amazing project.
Second, I'm using thinking sphinx in one of my projects. The project
is a product search engine for brazilian online stores. I have my
crawler developed in python and the website interface in rails (I was
going to use django, but I changed to rails just to use thinking
sphinx :)). The project is in an advanced stage, the search is
working, the faceting is working, etc. I have just some small
problems:
1. Thinking faceting does not seems to work with habtm relationships
(it kinda works, but if lets say I have a products associated with
category1 and category2, the facets returns like that =>
category1category2 (23), and NOT like => category1 (34) category
(23)... Am I doing something wrong? Please Pat, help me.
2. Is there a way of limiting the number of facets returned? Let me
explain. Suppose that I search for "xxxxx" and I'm faceting on Brands
(Product belongs_to Brand). It will return, let's say 21 different
brands. I want to return ONLY the TOP 5 brands (with the most count),
ordered by count DESC. Is this possible?
3. How can I sort the facets (by name or by count)? For now, it seems
to return in the exact order found in the database.
Please, take a look at my code for the products.rb and then for the
search_controller.rb
class Product < ActiveRecord::Base
belongs_to :store
belongs_to :brand
belongs_to :category
belongs_to :subcategory, :class_name => "Category", :foreign_key =>
'subcategory_id'
define_index do
indexes name, :as => :name
indexes store.name, :as => :store, :facet => true
indexes brand.name, :as => :brand, :facet => true
indexes category.name, :as => :category, :facet => true
indexes subcategory.name, :as => :subcategory, :facet => true
end
end
class SearchController < ApplicationController
def search
@query = params[:query]
@store = params[:store]
@brand = params[:brand]
@category = params[:category]
@subcategory = params[:subcategory]
if !(@query.blank? && @category.blank? && @subcategory.blank?)
@products = Product.search(@query, :conditions => {:store =>
@store, :brand => @brand, :category => @category, :subcategory =>
@subcategory})
@facets = Product.facets(@query, :conditions => {:store =>
@store, :brand => @brand, :category => @category, :subcategory =>
@subcategory})
end
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @products }
end
end
end
Do you have any suggestions for my code?
Please help me!
Thank you very much!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---