You can use boosters, so that surname results come before name results and surname&name results before surname results.
searchable do
text :surname, boost: 2.0
text :name, boost: 1.0
end
You ask any term to be matched and then order them descendingly on score. Results matching name and surname will score higher, only surname lower and only name lowest.
@search=User.search
fulltext "#{name_variable} #{surname_variable}", :minimum_match => 1
order_by(:score, :desc)
end