我是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 中有算法同时拥有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": []
}
}
我的结果是应该而不是必须,但这不是我一直在寻找的行为。
答案 0 :(得分:1)
默认standard analyzer会删除大多数标点符号,将文本分解为单个单词,并将其缩小。
所以可能C3244317被索引为c3244317,即小写' c'
您不需要这么大的查询。这应该可以正常工作:
{
"query":{
"bool":{
"must":[
{
"term":{
"doc.partes.algo.CUI":"c3244317"
}
},
{
"term":{
"doc.partes.algo.CUI":"c2926602"
}
}
]
}
}
}