嗨,我想使用完形暗示器使用elasticsearch创业板。
我尝试遵循ruby客户端文档,但是在使用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"
}
}
]
}
]
}但与红宝石客户不同:
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'
}
}
})发布于 2014-12-23 15:02:16
我发现了我的问题:
Article.__elasticsearch__.client.suggest(:index => Article.index_name, :body => {
:suggestions => {
:text => "s",
:completion => {
:field => 'suggest'
}
}
})发布于 2014-12-30 02:39:48
这是对我有用的。
Elasticsearch::Model.client.suggest index: 'articles',
body: {
suggestion: {
text: 's',
completion: {
field: 'suggest'
#suggest or any field that has mapping with type: 'completion', payloads: true
}
}
}https://stackoverflow.com/questions/27589122
复制相似问题