gpt4 book ai didi

string - Elasticsearch匹配数组中的相似句子

转载 作者:行者123 更新时间:2023-12-03 00:13:25 26 4
gpt4 key购买 nike

我正在使用Elasticsearch构建聊天机器人,但我不知道如何使其表现出我想要的效果。

我在索引“/ questions / q”中有这种格式的问题对象:

{
"name": "some question" //just for identification,
"questions": [
"Is ice cream good?",
"Is ice cream delicious?",
"Will i love the taste of ice cream?"
],
"response": "yes"
}

我想将输入问题与问题数组进行匹配,其中得分最高的是具有最佳单个匹配问题的对象。因此,从本质上讲,我希望对象的分数是该数组中最高问题的分数。

当前,我正在使用与此类似的查询:
{
"query": {
"match": {
"questions": {
"query": "where can i buy tickets"
}
}
}
}

但是如果数组很大,它给我的分数很低,因为我猜想它会使数组变成一个大字符串。

我应该针对该用例使用哪种查询?

最佳答案

您应该使用嵌套的数据类型,这样既可以解决您的问题,又可以防止诸如“爱情好吗?”之类的字符串。匹配这个问题集?

https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html上查看原因和方式

关于string - Elasticsearch匹配数组中的相似句子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38798831/

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