{"action":"closed","issue":{"url":"https://api.github.com/repos/pat/thinking-sphinx/issues/938","labels_url":"https://api.github.com/repos/pat/thinking-sphinx/issues/938/labels{/name}","comments_url":"https://api.github.com/repos/pat/thinking-sphinx/issues/938/comments","events_url":"https://api.github.com/repos/pat/thinking-sphinx/issues/938/events","html_url":"https://github.com/pat/thinking-sphinx/issues/938","id":103351452,"number":938,"title":"Handling has_many association through single index","user":{"login":"mattecalcio","id":1546187,"avatar_url":"https://avatars.githubusercontent.com/u/1546187?v=3","gravatar_id":"","url":"https://api.github.com/users/mattecalcio","html_url":"https://github.com/mattecalcio","followers_url":"https://api.github.com/users/mattecalcio/followers","following_url":"https://api.github.com/users/mattecalcio/following{/other_user}","gists_url":"https://api.github.com/users/mattecalcio/gists{/gist_id}","starred_url":"https://api.github.com/users/mattecalcio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattecalcio/subscriptions","organizations_url":"https://api.github.com/users/mattecalcio/orgs","repos_url":"https://api.github.com/users/mattecalcio/repos","events_url":"https://api.github.com/users/mattecalcio/events{/privacy}","received_events_url":"https://api.github.com/users/mattecalcio/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-26T19:54:52Z","updated_at":"2015-08-26T21:47:06Z","closed_at":"2015-08-26T21:47:06Z","body":"Hey Pat\r\n\r\nI have the following models:\r\n\r\n```\r\nclass User < ActiveRecord::Base\r\n   has_many :locations\r\n   ...\r\nend\r\n```\r\n```\r\nclass Location < ActiveRecord::Base\r\n   belongs_to :user\r\n   ...\r\nend\r\n```\r\n\r\nand the following index on `User`:\r\n\r\n```\r\nThinkingSphinx::Index.define :user, name: :user, with: :active_record do\r\n   indexes name, as: :user_name\r\n\r\n   has 'RADIANS(location.latitude)', as: :lat, type: :float\r\n   has 'RADIANS(location.longitude)', as: :lng, type: :float\r\n\r\n   join locations\r\nend\r\n```\r\n\r\nand this is how I search:\r\n\r\n`User.search(geo: [lat, lng], with: {geodist: 0.0..10_000.0})`\r\n\r\nAfter running `ts:rebuild` it seems as though only the first location of the user was indexed and Ideally I would like all locations to be available when searching to provide more accurate results.\r\n\r\nIs there a way to alter the existing index to take into account the has_many association of user on locations?\r\n\r\nI know I could create an index on `Location` and search using that but there are a lot of other attributes on the `User` index (omitted for simplicity since they rely on other `User` associations) that I would like to use for the search. Also creating an additional index would require a second search to retrieve the `User` from the `Location`.\r\n"}}