【发布时间】:2015-02-19 18:02:10
【问题描述】:
您好,我想通过 elasticsearch-rails gem 使用completion suggester。
我尝试关注 ruby 客户端 documentation,但在使用 postman 和 rails 客户端时我没有相同的结果。
与邮递员合作:
{
"suggestions" : {
"text" : "s",
"completion" : {
"field" : "suggest"
}
}
}
结果:
{
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"suggestions": [
{
"text": "s",
"offset": 0,
"length": 3,
"options": [
{
"text": "superman",
"score": 1,
"payload": {
"id": 922,
"tumb_img": "/user/avatar/20/thumb_img.jpg"
}
}
]
}
]
}
但不是 ruby 客户端:
Article.__elasticsearch__.client.suggest(:index => '', :body => {
:suggestions => {
:text => "s",
:term => {
:field => 'suggest'
}
}
})
结果:
{
"_shards": {
"total": 11,
"successful": 11,
"failed": 0
},
"suggestions": [
{
"text": "s",
"offset": 0,
"length": 1,
"options": []
}
]
}
我也尝试用完成替换术语,但仍然不起作用:
Article.__elasticsearch__.client.suggest(:index => '', :body => {
:suggestions => {
:text => "s",
:completion => {
:field => 'suggest'
}
}
})
【问题讨论】:
标签: ruby-on-rails ruby autocomplete elasticsearch