3
您好我想使用elasticsearch-rails gem的completion suggester。elasticsearch-rails寶石 - 完成建議
我試圖按照紅寶石客戶端documentation,但使用郵遞員和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"
}
}
]
}
]
}
但不可用紅寶石客戶端:
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'
}
}
})