Answer the question
In order to leave comments, you need to log in
How to enable related table sorting when using thinking_sphinx?
For example, there are two tables: books (id, title, date) and authors (id, name, country, date). When searching for a book, I display all information about the author. Those. As a result, we see the columns:
books.id, books.title, books.created_at, authors.name, authors.country, authors.created_at
ThinkingSphinx::Index.define :book, with: :real_time do
indexes title, sortable: true
indexes author.name, as: :author_name, sortable: true
indexes author.country, as: :author_country, sortable: true
has title, type: string
has author.name, type: string
has author.country, type: string
has created_at, type: :timestamp
has author.created_at, type: :timestamp
end
Book.search params[:search], sql: {include: :author}, order: 'author_name asc'
index book_core: sort_by attribute 'author_name' not found - SELECT * FROM 'book_core' WHERE MATCH('blablabla') AND 'sphinx_deleted' = 0 ORDER BY 'author_name' asc LIMIT 0, 50; SHOW META
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question