So I'd like to use Thinking Sphinx purely as a tool to allow the user to 
order some associated companies based on location.  Here is the important 
information in my index:

ThinkingSphinx::Index.define :company, :with => :active_record do
>   # Attributes (cannot be text)
>   has id, :as => :company_id
>   has longitude, :as => :lng, :type => :float
>   has lattitude, :as => :lat, :type => :float # Forgive the spelling error
> end


rake ts:rebuild done, and here is my console log:

> c = Company.find(53766); "Base: #{c.city}, #{c.state} [#{c.lattitude}, 
> #{c.longitude}]"
> "Base: Oak Park, Michigan [42.46714, -83.15695]"
>
 

> Company.search(:indices => ['company_core'], :geo => [c.lattitude, 
> c.longitude], :order => "geodist ASC").map{|c| "#{c.city}, #{c.state} 
> [#{c.lattitude}, #{c.longitude}] (#{c.id})" }
> [
>     [ 0] "Oak Park, Michigan [42.46714, -83.15695] (276075)",
>     [ 1] "Ferndale, Michigan [42.46672, -83.1259] (3419)",
>     [ 2] "Ferndale, Michigan [42.46825, -83.12812] (3214)",
>     [ 3] "Tulsa, Oklahoma [36.18352, -95.7884] (82944)",
>     [ 4] "Ferndale, Michigan [42.46381, -83.12867] (47512)",
>     [ 5] "Houston, Texas [29.89859, -95.66493] (143434)",
>     [ 6] "Greensboro, North Carolina [36.07354, -79.94699] (8618)",
>     [ 7] "Catoosa, Oklahoma [36.18007, -95.72873] (26684)",
>     [ 8] "Ferndale, Michigan [42.46246, -83.12375] (101585)",
>     [ 9] "coimbatore, Tamil Nadu [10.94272, 76.97917] (89942)",
>     [10] "coimbatore, Tamil Nadu [10.94272, 76.97917] (217885)",
>     [11] "Warren, Michigan [42.47056, -83.08191] (24528)",
>     [12] "Houston, Texas [29.8968, -95.65148] (79232)",
>     [13] "Hazel Park, Michigan [42.47218, -83.10462] (4132)",
>     [14] "Casilda  -  Santa Fe,  [-33.0483, -61.14761] (65558)",
>     [15] "Ferndale, Michigan [42.47307, -83.1332] (107970)",
>     [16] "Warren, Michigan [42.46676, -83.04572] (4209)",
>     [17] "Warren, Michigan [42.46676, -83.04572] (91989)",
>     [18] "Houston, Texas [29.8996, -95.61071] (4534)",
>     [19] "Warren, Michigan [42.46892, -83.04759] (9379)"
> ]


And here is what was logged as the query:

  SELECT *, GEODIST(42.46714, -83.15695, lat, lng) AS geodist FROM 
> `company_core` WHERE MATCH('@sphinx_internal_class_name (Company)') AND 
> sphinx_deleted = 0 ORDER BY geodist ASC LIMIT 0, 20 OPTION max_matches=5000


The first few results are not bad, though I would have thought the base 
company would have appeared first.  Then things get even stranger.  Is 
there something fundamental that I am doing incorrect here?

-Lonnie

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to