【发布时间】:2020-02-14 06:32:45
【问题描述】:
我想搜索所有 role_id 为 8 且 status.id 为 5 的文档。我的数据有以下索引。
我尝试通过以下查询仅通过 role_id 为 8 获取数据
{
"query": {
"bool": {
"filter": [
{ "match" : {"role.role_id" : 8} }
]
}
}
}
它返回 "hits": [] 不确定这里出了什么问题。
我是弹性搜索的新手,我看到很多文档都提到了对象的嵌套类型。这是强制性的吗?我需要更改索引吗?
{
"contacts": {
"aliases": {},
"mappings": {
"properties": {
"roles": {
"properties": {
"role_id": {
"type": "long"
},
"role_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"status": {
"properties": {
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch