gpt4 book ai didi

elasticsearch - 多字段匹配查询

转载 作者:行者123 更新时间:2023-11-29 02:43:39 25 4
gpt4 key购买 nike

我是 Elasticsearch 的新手,想编写一个关注两个字段的查询。我的意思是字段的内容包含指定的子字符串。我有一个包含字段的文档,如下所示:

name: n
tag: t

我试过这个:

/_search -d '
{
"query": {
"match": {
"name": "n",
"tag": "t"
}
}
}

但是查询结果出现以下错误:

[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?

有没有办法在 elasticsearch 中做到这一点?

最佳答案

您需要两个包含在 bool/must 查询中的 match 查询,如下所示:

{
"query": {
"bool": {
"must": [
{
"match": {
"name": "n"
}
},
{
"match": {
"tag": "t"
}
}
]
}
}
}

关于elasticsearch - 多字段匹配查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39507005/

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