我有两个模型(Post和Comment),我想用elasticsearch搜索它们。Post模型有一个字段popolarity,它是表示post的流行性的整数。
我使用的是am elasticsearch-model,现在我想用一个查询在Posts和Comments上搜索,这很好
Elasticsearch::Model.search('search string', [Post, Comment])现在,我想添加一个选项,通过它的Post字段(如因受欢迎而增强中所描述的)来增强因受欢迎而增强元素。我尝试了一下Ruby,这有可能吗?喜欢
Elasticsearch::Model.search('antilope', [Post, Comment], field_value_factor: {field: 'clicks'})但这给了我这个错误
ArgumentError:不支持URL参数'field_value_factor‘
发布于 2015-09-03 06:42:50
您应该能够通过传递这样一个完整的function-score查询来完成这个任务:
Elasticsearch::Model.search({
"query": {
"function_score": {
"query": {
"match": {
"_all": "antilope"
}
},
"field_value_factor": {
"field": "clicks"
}
}
}
}, [Post, Comment])https://stackoverflow.com/questions/32365624
复制相似问题