【发布时间】:2017-11-21 00:13:48
【问题描述】:
我是 Elastic Search 的新手。
我已经在 elasticsearch 中索引了下一个对象:
"doc": [
{
"partes": [
{
"algo": [
{
"Category": "Therapeutic or Preventive Procedure",
"Neg": "false",
"CandidatePreferred": "Obstetric Surgical Procedures",
"CandidateScore": "1000",
"CandidateMatched": "Obstetric Surgical",
"Phrase": "OBSTETRIC SURGICAL",
"CUI": "C0038906"
}
]
}
]
},
{
"partes": [
{
"algo": [
{
"Category": "Intellectual Product",
"Neg": "false",
"CandidatePreferred": "Given name",
"CandidateScore": "790",
"CandidateMatched": "given",
"Phrase": "given of discharge",
"CUI": "C3244317"
},
{
"Category": "Body Substance",
"Neg": "false",
"CandidatePreferred": "Discharge, body substance",
"CandidateScore": "790",
"CandidateMatched": "Discharge",
"Phrase": "given of discharge",
"CUI": "C2926602"
}
]
},
{
"algo": [
{
"Category": "Health Care Activity",
"Neg": "false",
"CandidatePreferred": "Patient Discharge",
"CandidateScore": "790",
"CandidateMatched": "Discharge",
"Phrase": "given of discharge",
"CUI": "C0030685"
},
{
"Category": "Intellectual Product",
"Neg": "false",
"CandidatePreferred": "Given name",
"CandidateScore": "790",
"CandidateMatched": "given",
"Phrase": "given of discharge",
"CUI": "C3244317"
}
]
}
]
}
]
}
}
我的目标是获取在同一元素 algo 中有两个 CUI 的元素,即 doc 中有一个 algo 谁同时拥有 CUI:C3244317 和 C2926602。
我正在尝试进行下一次搜索:
{
"query": {
"nested": {
"path": "doc",
"query": {
"nested":{
"path":"doc.partes",
"query": {
"nested": {
"path":"doc.partes.algo",
"query": {
"bool": {
"must": [
{ "term": { "doc.partes.algo.CUI": "C3244317" }},
{ "term": { "doc.partes.algo.CUI": "C2926602" }}
]
}
}
}
}
}
}
}
}
}
但我没有任何结果:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
我得到了 should 而不是 must 的结果,但这不是我一直在寻找的行为。
【问题讨论】:
标签: elasticsearch elasticsearch-2.0