搜索踢:提升未来的约会



我在带有ElasticSearch 6.8服务器的Rails项目中使用Searchkick。我正在尝试提升某些文档,这些文档的年份字段等于今年或未来一年。

我尝试使用boost_where,最近一次boost_by但都不起作用。boost_by生成一个在 ElasticSearch 中出错的function_score函数。这是我最近的尝试。

Model.search('value', boost_by: { year: { scale: '5y' } })

ElasticSearch似乎不喜欢日历间隔(5y(,即使这应该是有效的。下面是错误的原因对象:

"caused_by": {
"type": "number_format_exception",
"reason": "For input string: "5y""
}

我尝试设置origindecay以及scale但这似乎没有任何帮助。

下面是 Searchkick 生成的查询(由于非常特定的域模型而更改了模型和字段名称(。

Model Search (163.5ms)  model_development/_search {"query":{"function_score":{"functions":[{"weight":1,"gauss":{"year":{"scale":"5y"}}}],"query":{"bool":{"should":[{"dis_max":{"queries":[{"multi_match":{"query":"Abreu","boost":10,"operator":"and","analyzer":"searchkick_search","fields":["*.analyzed"],"type":"best_fields"}},{"multi_match":{"query":"Abreu","boost":10,"operator":"and","analyzer":"searchkick_search2","fields":["*.analyzed"],"type":"best_fields"}},{"multi_match":{"query":"Abreu","boost":1,"operator":"and","analyzer":"searchkick_search","fuzziness":1,"prefix_length":0,"max_expansions":3,"fuzzy_transpositions":true,"fields":["*.analyzed"],"type":"best_fields"}},{"multi_match":{"query":"Abreu","boost":1,"operator":"and","analyzer":"searchkick_search2","fuzziness":1,"prefix_length":0,"max_expansions":3,"fuzzy_transpositions":true,"fields":["*.analyzed"],"type":"best_fields"}}]}}]}},"score_mode":"sum"}},"timeout":"11s","_source":false,"size":10000}

年份可能不是受支持的日期格式,因为它没有绝对表示形式。一天总是24 小时,但一年有时是 364 天,通常是365 天。ES不会解决这种复杂性,而是可能会在几天内停止。

如果需要,您可以改用天数作为体重秤:

Model.search('value', boost_by: { year: { scale: '1825d' } })

相关内容

  • 没有找到相关文章

最新更新