以下是完整的錯誤消息:默認情況下,字段數據在文本字段中處於禁用狀態。設置fielddata =真
Searchkick::InvalidQueryError: Searchkick::InvalidQueryError: [400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [foo_name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"foos_test","node":"k0yYkVnIQzaXbvpAG_rKgw","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [foo_name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [foo_name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}},"status":400}
我得到這個錯誤(這個錯誤只顯示在MINITEST)當我添加索引操作代碼如下:
order: {foo_name: :asc}
這裏是我的完整的索引代碼:
def index
query = params[:q].presence || "*"
@foos = Foo.search(
query,
page: params[:page], per_page: 25,
order: {foo_name: :asc}
)
end
end
我正在使用Searchkick。