无法按 asc 顺序对 elasticsearch 中的自定义方法(列)进行排序

Unable to sort in asc order for a custom methods(column) in elasticsearch

module Indexing
    def as_indexed_json(options={})
      self.as_json({
        include: { data: { only: [:some_data] } },
        methods: [:method_one, :method_two, :method_three]
        })
    end
  end

method_two 是字符串列。

无法使用 elasticsearch 模型使用 method_two 列按 asc 顺序排序,但同样可以按 desc 顺序进行排序。

我之前遇到过类似的问题。

您只需为映射中的列添加索引

mapping do
  indexes :method_two, type: :string, index: :not_analyzed
end