2008-11-05 3 views
1

검색 용으로 인덱싱 된 두 개의 모델 (사용자 및 항목)이 있습니다. 전 모델에 걸쳐 지리적 검색 할 노력하고있어 :ThinkingSphinx로 여러 모델을 어떻게 검색합니까?

ThinkingSphinx::Search.search('keywords', :geo => [ degrees_to_radians(params[:lat].to_f), degrees_to_radians(params[:lon].to_f) ], )

을하지만 난 단지 오류 얻을 : 각 모델은 개별적으로 잘 작동 검색

Sphinx Error: index item_core,item_delta,user_core,user_delta: unknown latitude attribute ''

을 ...하지만 난 ' 이 문제가 뭔지 전혀 몰랐습니다.

사용자 색인 :

define_index do 
    indexes [:first_name, :last_name], :as => :name 
    indexes login 
    indexes email 
    indexes headline 
    indexes description 
    indexes business.name, :as => :business_name 
    indexes [addresses.street_1, addresses.street_2, addresses.city, addresses.postal_code], :as => :address 

    has created_at, :sortable => true 
    has addresses.latitude, :as => :latitude, :type => :float 
    has addresses.longitude, :as => :longitude, :type => :float  

    set_property :delta => true 
    end  

항목 지수 :

define_index do 
    indexes title, :sortable => true 
    indexes description 
    indexes [address.street_1, address.street_2, address.city, address.postal_code], :as => :address 
    indexes images.title, :as => :image_titles 
    indexes images.description, :as => :image_descriptions 
    indexes categories(:name), :as => :category_names  

    has price, :sortable => true 
    has created_at, :sortable => true 
    has address.latitude, :as => :latitude, :type => :float 
    has address.longitude, :as => :longitude, :type => :float  
    has categories(:id), :as => :category_ids 

    where "`items`.`state` = 'for_sale'" 

    set_property :delta => true  
    end 

답변

3

이 잘하면, 아무것도보다 더 늦은 반응이지만, 다음은 인덱스입니다 당신이있어

특정 모델을 검색하지 않는다면 Thinking Sphinx는 사용할 수있는 속성을 알기위한 참조 점이 없으므로 사용할 위도 및 경도를 명시해야합니다.

ThinkingSphinx::Search.search('keywords', 
    :geo => [ 
    degrees_to_radians(params[:lat].to_f), 
    degrees_to_radians(params[:lon].to_f) 
    ], 
    :latitude_attr => "latitude", 
    :longitude_attr => "longitude" 
) 
관련 문제