[英]Completion Suggester in elasticsearch in mutifield
I'm using elasticsearch for the first time. 我第一次使用elasticsearch。 I'm trying to use completion suggester in multi-field key, although I don't see any error but I don't get the response. 我正在尝试在多字段键中使用完成建议程序,尽管我没有看到任何错误,但没有得到响应。
Mapping creation: 映射创建:
PUT /products5/
{
"mappings":{
"products" : {
"properties" : {
"name" : {
"type":"text",
"fields":{
"text":{
"type":"keyword"
},
"suggest":{
"type" : "completion"
}
}
}
}
}
}
}
Indexing: 索引:
PUT /products5/product/1
{
"name": "Apple iphone 5"
}
PUT /products5/product/2
{
"name": "iphone 4 16GB"
}
PUT /products5/product/3
{
"name": "iphone 3 SS 16GB black"
}
PUT /products5/product/4
{
"name": "Apple iphone 4 S 16 GB white"
}
PUT /products5/product/5
{
"name": "Apple iphone case"
}
Query: 查询:
POST /products5/product/_search
{
"suggest":{
"my-suggestion":{
"prefix":"i",
"completion":{
"field":"name.suggest"
}
}
}
}
Output: 输出:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": 0,
"hits": []
},
"suggest": {
"my-suggestion": [
{
"text": "i",
"offset": 0,
"length": 1,
"options": []
}
]
}
}
Please guide me what is the mistake, I tried every possible options. 请指导我这是什么错误,我尝试了所有可能的选择。
From the first perspective this looks accurate. 从第一个角度看,这看起来很准确。 Probably the reason why you don't have correct response is that you added documents in the index before you created mapping in the index. 可能没有正确响应的原因是,在索引中创建映射之前,已在索引中添加了文档。 And documents are not indexed according to the mapping you specified 并且未根据您指定的映射对文档建立索引
I have found an issue in your mapping name. 我在您的映射名称中发现了一个问题。 There is an inconsistency between name of the mapping and value which you specifies in the url when you're creating new documents. 创建新文档时,映射名称与您在url中指定的值之间存在不一致。 You create a mapping in the index with the name products
. 您在索引中使用名称products
创建一个映射。 And when you add new documents you're specifying product
as a name of the mapping of your index and it doesn't end with s
. 当您添加新文档时,您要指定product
作为索引映射的名称,并且不以s
结尾。 You have a typo. 你有错字
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.