【发布时间】:2022-11-05 00:23:53
【问题描述】:
我有以下弹性搜索索引
{
"companies": {
"aliases": {},
"mappings": {
"properties": {
"industries": {
"type": "nested",
"properties": {
"_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"description": {
"type": "text"
},
"priority": {
"type": "integer"
},
"title": {
"type": "text"
}
}
}
}
}
}
}
我想搜索所有行业数组包含带有_id = 81ca8f45-5b6a-11ed-96b4-0242ac110002 的标签的公司。
我尝试了以下查询,但我无法让它匹配任何文档。
{
"query": {
"bool": {
"should": [
{
"nested": {
"path": "industries",
"query": {
"bool": {
"should": [
{
"term": {
"industries._id": "81ca8f45-5b6a-11ed-96b4-0242ac110002"
}
}
]
}
}
}
},
{
"term": {
"industries._id": "81ca8f45-5b6a-11ed-96b4-0242ac110002"
}
}
]
}
}
}
甚至可以匹配 _id 字段吗?因为我测试了以下术语查询,它返回了一个很好的结果。
{
"query": {
"bool": {
"should": [
{
"term": {
"industries.priority": 1
}
}
]
}
}
}
【问题讨论】:
标签: php elasticsearch ongr