我有这个返回始终为null的查询:
{
"query": {
"bool": {
"should": {
"nested": {
"query": {
"bool": {
"must": [
{
"term": {
"old": false
}
}
]
}
},
"path": "jobOffers"
}
}
}
}
}
这里有什么匹配所有回报:
{
"hits": [{
"_index": "dev",
"_type": "recruitment",
"_id": "202837r",
"_score": 1,
"_routing": "202837",
"_parent": "202837",
"_source": {
"score": 1,
"jobOffers": [{
"jobId": "jksncdjkqsnhcjkqs",
"jobCompany": "company 1",
"jobTitle": "Comptable",
"old": false
}],
"totalCount": 1
}
},
{
"_index": "dev",
"_type": "recruitment",
"_id": "202838r",
"_score": 1,
"_routing": "202838",
"_parent": "202838",
"_source": {
"score": 1,
"jobOffers": [{
"jobId": "wxjkckjwxhcmlazdkklqjkcn",
"jobCompany": "company 2",
"jobTitle": "Commercial",
"old": false
},
{
"jobId": "lxjkckazdwxctrzadjkoo",
"jobCompany": "company 2",
"jobTitle": "Chargé de développement commercial",
"old": false
}
],
"totalCount": 2
},
...
}
我确定我正在查询正确的索引和正确的类型。这种行为是否正常?如何让它返回预期的结果?
答案 0 :(得分:1)
在您的查询中,您需要撰写jobOffers.old
而不仅仅是old
{
"query": {
"bool": {
"should": {
"nested": {
"query": {
"bool": {
"must": [
{
"term": {
"jobOffers.old": false <--- modify this
}
}
]
}
},
"path": "jobOffers"
}
}
}
}
}