Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I geo-search multiple models with ThinkingSphinx?
    text
    copied!<p>I have two models indexed for searching (User and Item). I'm trying to do a geo-search across models:</p> <p><code>ThinkingSphinx::Search.search('keywords', :geo =&gt; [ degrees_to_radians(params[:lat].to_f), degrees_to_radians(params[:lon].to_f) ], )</code></p> <p>But I only get an error: </p> <p><code>Sphinx Error: index item_core,item_delta,user_core,user_delta: unknown latitude attribute ''</code></p> <p>Searching each model individually works fine... but I've no idea what the problem here is. Here are the indexes:</p> <p>User Index:</p> <pre><code>define_index do indexes [:first_name, :last_name], :as =&gt; :name indexes login indexes email indexes headline indexes description indexes business.name, :as =&gt; :business_name indexes [addresses.street_1, addresses.street_2, addresses.city, addresses.postal_code], :as =&gt; :address has created_at, :sortable =&gt; true has addresses.latitude, :as =&gt; :latitude, :type =&gt; :float has addresses.longitude, :as =&gt; :longitude, :type =&gt; :float set_property :delta =&gt; true end </code></pre> <p>Item index:</p> <pre><code>define_index do indexes title, :sortable =&gt; true indexes description indexes [address.street_1, address.street_2, address.city, address.postal_code], :as =&gt; :address indexes images.title, :as =&gt; :image_titles indexes images.description, :as =&gt; :image_descriptions indexes categories(:name), :as =&gt; :category_names has price, :sortable =&gt; true has created_at, :sortable =&gt; true has address.latitude, :as =&gt; :latitude, :type =&gt; :float has address.longitude, :as =&gt; :longitude, :type =&gt; :float has categories(:id), :as =&gt; :category_ids where "`items`.`state` = 'for_sale'" set_property :delta =&gt; true end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload