太阳黑子,Solr,order_by,编码

Lui*_*sta 4 solr ruby-on-rails sunspot

排序时我遇到了太阳黑子问题和一些问题.主要问题是使用带有重音符号的巴西单词.例如,对于一组名称:

  • 阿尔贝托
  • 安娜
  • 玛丽亚
  • 阿尔瓦罗

Álvaro这个名字在调用order_by方法后总是出现在列表的末尾.

这是列名的类设置:

class Student < ActiveRecord::Base
 searchable do
   text(:name)
   text(:code)
   string :name_sort do 
     name
   end
 end

 def search(options)
    students = Student.search do 
      fulltext(options[:data])
      order_by :name_sort
    end
    students.results
 end
end
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?谢谢路易斯

And*_*i S 6

索引时可以尝试使用音译

class Student < ActiveRecord::Base
  searchable do
    text(:name)
    text(:code)
    string :name_sort do 
      I18n.transliterate name
    end
  end

  def search(options)
    students = Student.search do 
      fulltext(options[:data])
      order_by :name_sort
    end
    students.results
  end
end
Run Code Online (Sandbox Code Playgroud)