searchkick rails 5中的支持范围和布尔项条件?

时间:2018-01-24 07:12:14

标签: searchkick ruby-on-rails-5.1

我在我的Rails 5应用程序中使用Searchkick,我正在尝试在app中支持范围和布尔条件条件。

我的范围查询,例如:

Model.search '*', where: { _or: [ { age_years: { gte: "5", lte: "7" } } ] }

但我收到如下错误:

"caused_by":{"type":"illegal_argument_exception","reason":"Cannot search on field [age_years] since it is not indexed."}

我也尝试过使用aggs查询:

options = {:aggs=>{:age_years=>{:ranges=>[{:from=>7, :to=> 12}]}}} Model.search("*", options)

但我收到如下错误:

{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [age_years] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}

我的术语查询如下:

Model.search "*", where: {lc_vet_care: true}

但是我没有索引错误与查询错误的范围相同。

如何使用searchkick修复此问题?

0 个答案:

没有答案