Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql_options defined per model #1120

Merged
merged 1 commit into from
Oct 19, 2018
Merged

Conversation

xronos-i-am
Copy link
Contributor

When multiple indices defined in search it becomes almost impossible to define sql includes. Different models has different relations usually

class City < ApplicationRecord
  has_one :overall_stat
  belongs_to :country
end

class Country < ApplicationRecord
  has_many :cities
end

This woudn't work

ThinkingSphinx.search("*", indices: %w(country_core city_core), sql: {include: [:overall_stat, :country]})

I suggest to define :sql option in the following maner (with fallback to previous variant):

ThinkingSphinx.search("*", indices: %w(country_core city_core), sql: {'City' => {include: [:overall_stat, :country]}})

@pat
Copy link
Owner

pat commented Oct 19, 2018

This is a neat change, thank you :)

@pat pat merged commit 2b2b5af into pat:develop Oct 19, 2018
@pat
Copy link
Owner

pat commented Dec 28, 2018

Just published v4.1.0 which includes this feature :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants