Ok, so I feel really stupid now, I forgot to put quotation marks around RADIANS(lat) and RADIANS(lng), so it indexes fine with those lines now...but still having an issue returning results.
When I index the model, it shows 5 reads and 10 writes, but nothing comes up in the search results. On Oct 7, 9:41 am, FelixG <[email protected]> wrote: > Sorry to post so many times, I just looked in my > development.sphinx.conf file as saw this query: > > sql_query = SELECT SQL_NO_CACHE `business_locations`.`id` * 1 + > 0 AS `id` , `business_locations`.`name` AS `name`, > `businesses`.`description` AS `description`, > `business_locations`.`name` AS `business`, `business_locations`.`name` > AS `category`, `business_locations`.`name` AS `subcategory`, > `business_locations`.`id` AS `sphinx_internal_id`, 2578238160 AS > `class_crc`, 0 AS `sphinx_deleted`, > IFNULL(`business_locations`.`name`, '') AS `name_sort`, > `business_locations`.`#<ThinkingSphinx::Index::FauxColumn: > 0x000000042e24b8>` AS `latitude`, > `business_locations`.`#<ThinkingSphinx::Index::FauxColumn: > 0x000000042e2210>` AS `longitude`, `business_locations`.`business_id` > AS `business_id`, UNIX_TIMESTAMP(`business_locations`.`created_at`) AS > `created_at`, UNIX_TIMESTAMP(`business_locations`.`updated_at`) AS > `updated_at` FROM `business_locations` LEFT OUTER JOIN > `businesses` ON `businesses`.`id` = `business_locations`.`business_id` > WHERE (`business_locations`.`id` >= $start AND > `business_locations`.`id` <= $end) GROUP BY `business_locations`.`id` > ORDER BY NULL > > If I remove the lines for has RADIANS(lat) and RADIANS(lng), it > indexes the model, but when I geo-search through it, it doesn't return > any results > > Any suggestions? > > Thank you, > > On Oct 7, 9:29 am, FelixG <[email protected]> wrote: > > > > > Hi Pat, > > > Thank you so much for answering my question and providing that code to > > get me started. > > > So I have this code in my BusinessLocation model now, but I get this > > error when I try to index: > > > ERROR: index 'business_location_core': sql_query_range: : macro > > '$start' not found in match fetch query. > > > Here is my define_index block:http://pastie.org/1205271 > > > On Oct 6, 8:35 pm, Pat Allan <[email protected]> wrote: > > > > Hi Felix > > > > Sphinx can only deal with single lat/lng pairs for each record - so > > > you're going to have to have the index on the address model. However, you > > > can group search results by attributes - so if you have the company_id as > > > an attribute, you can limit results to one address per company. > > > > And you can access category and sub_category associations via the company > > > association in your index definition: > > > > define_index do > > > indexes company.name, :as => :company > > > indexes company.category.name, :as => :category > > > indexes company.sub_category.name, :as => :subcategory > > > > has company_id, latitude, longitude > > > end > > > > Address.search "foo", :geo => [...@lat, @lng], :group_by => 'company_id' > > > > So, in short - yes it's possible :) > > > > Cheers > > > > -- > > > Pat > > > > On 07/10/2010, at 10:13 AM, FelixG wrote: > > > > > Also, I forgot to mention, I have 2 more models called category and > > > > sub_category. They belong to Company but not to Address. > > > > > If I index the Address model with the Company attributes, I won't be > > > > able to access the category and sub_category. > > > > > Is there a way to index the company model so that it accepts multiple > > > > addresses for each company? > > > > > On Oct 6, 6:56 pm, FelixG <[email protected]> wrote: > > > >> I'm thinking of integrating thinking_sphinx into my app but I am > > > >> curious if this is possible. > > > >> Currently I have a Company model and an Address model. > > > >> Each company can have many addresses in the address model. > > > > >> Is it possible to index each address for a company with thinking > > > >> sphinx and then do geo-searching on that? > > > > >> Any help is appreciated. Thank you. > > > > > -- > > > > 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 > > > > athttp://groups.google.com/group/thinking-sphinx?hl=en. -- 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.
