【发布时间】:2021-12-06 19:26:45
【问题描述】:
我是弹性搜索的新手,我正在尝试搜索具有以下属性的索引:
// user index
{
profile: {
name: string,
description: string,
city: string
state: string
},
services: [
{
serviceName: string
},
{
serviceName: string
},
{
serviceName: string
},
...
]
}
我正在尝试合并我的 query_string 和 nested,但我似乎无法让它工作。
body: {
query: {
query_string: {
query: `*${searchTerm}*`,
fields: [
// these profile fields work
'profile.name',
'profile.description',
'profile.city',
'profile.state',
// doesnt work, need to use nested
'services.serviceName'
]
},
// if i use nested here, elasticsearch throws error
// can I combine these two queries like this?
nested: {
}
}
}
我找不到任何同时具有 nested 和 query_string 搜索查询的好示例。
大家有什么建议吗?
任何有帮助的东西,甚至是我正在尝试做的事情的优秀文档/示例的链接。
【问题讨论】:
标签: elasticsearch search