gpt4 book ai didi

elasticsearch - 在完成提示器上嵌套的 “dot”字段

转载 作者:行者123 更新时间:2023-12-02 22:48:08 26 4
gpt4 key购买 nike

我想使用嵌套的“点”字段作为完成提示的键(使用ElasticSearch 6.4)。这很好用:

PUT music/_doc/1?refresh
{
"suggest.music" : {
"input": [ "Nevermind", "Nirvana" ],
"weight" : 34
}
}

...但是此建议查询不起作用:
POST music/_search?pretty
{
"suggest": {
"song-suggest" : {
"prefix" : "nir",
"completion" : {
"field" : "suggest.music"
}
}
}
}

它说:“找不到字段[suggest.music]的映射”。这是我的映射:
{
"music" : {
"aliases" : { },
"mappings" : {
"_doc" : {
"properties" : {
"es_suggest" : {
"type" : "completion",
"analyzer" : "simple",
"preserve_separators" : true,
"preserve_position_increments" : true,
"max_input_length" : 50
},
"suggest" : {
"properties" : {
"music" : {
"properties" : {
"input" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"weight" : {
"type" : "long"
}
}
}
}
},
"title" : {
"type" : "keyword"
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "1550842862212",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "Dqr3XQJWTqC5YRvJjEvh5w",
"version" : {
"created" : "6060099"
},
"provided_name" : "music"
}
}
}
}

有什么方法可以查询带有嵌套“点”字段的完成建议?

最佳答案

您正在尝试从不是完成字段suggest.music的字段完成操作。在您的映射中,es_suggest是完成字段。

如果需要,您可以更改映射以在嵌套对象中具有完成字段:

PUT music
{
"aliases" : { },
"mappings" : {
"_doc" : {
"properties" : {
"suggest" : {
"properties" : {
"music" : {
"properties" : {
"input" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"completion": {
"type": "completion",
"analyzer" : "simple",
"preserve_separators" : true,
"preserve_position_increments" : true,
"max_input_length" : 50
}
}
}
}
}
}
},
"title" : {
"type" : "keyword"
}
}
}
}
}

然后,您可以使用该字段来完成:
POST music/_search
{
"suggest": {
"song-suggest" : {
"prefix" : "nir",
"completion" : {
"field" : "suggest.music.input.completion"
}
}
}
}

关于elasticsearch - 在完成提示器上嵌套的 “dot”字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55249607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com