"Match" and "Range" "DSL query" in elastic search doesn't work?

1.3k views Asked by At

can anyone help ?

the query is run successfully as the separated "match query" and "range query" , but i get error when run this

this is my query but i cant get the result :

GET composition_value/composition/_count
{

  "query": {
    "nested": {
      "path": "value",
      "query": {
        "match": {
          "value.composition.content.data.events.data.items.name.value": "systolic"
        }, 
        "range": {
          "value.composition.content.data.events.data.items.value.magnitude": {
            "gte": 10,
            "lte": 99
          }
        }   
      }

    }
  }

}

here is the error , result of the query:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
        "line": 10,
        "col": 9
      }
    ],
    "type": "parsing_exception",
    "reason": "[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
    "line": 10,
    "col": 9
  },
  "status": 400
}

Edited

the problem is i want just "magnitude" filed in "systolic" not other

Here is the main Document i search on it:

  {
    "composition": {
        "name": {
            "value": "Avaexample1"
        },
        "archetype_details": {
            "archetype_id": {
                "value": "openEHR-EHR-COMPOSITION.avaexample1.v0"
            },
            "template_id": {
                "value": "New Template"
            },
            "rm_version": "1.0.2"
        },
        "language": {
            "terminology_id": {
                "value": "ISO_639-1"
            },
            "code_string": "en"
        },
        "territory": {
            "terminology_id": {
                "value": "ISO_3166-1"
            },
            "code_string": "UY"
        },
        "category": {
            "value": "event",
            "defining_code": {
                "terminology_id": {
                    "value": "openehr"
                },
                "code_string": "433"
            }
        },
        "composer": {
            "external_ref": {
                "id": {
                    "value": "ecd01eaf-775a-43c9-8b4b-1a9ba0257568",
                    "_xsi:type": "HIER_OBJECT_ID"
                },
                "namespace": "DEMOGRAPHIC",
                "type": "PERSON"
            },
            "name": "Dr. Yamamoto",
            "_xsi:type": "PARTY_IDENTIFIED"
        },
        "context": {
            "start_time": {
                "value": "20170723T122153,184+0430"
            },
            "setting": {
                "value": "Hospital B",
                "defining_code": {
                    "terminology_id": {
                        "value": "openehr"
                    },
                    "code_string": "229"
                }
            }
        },
        "content": {
            "name": {
                "value": "Blood pressure"
            },
            "language": {
                "terminology_id": {
                    "value": "ISO_639-1"
                },
                "code_string": "en"
            },
            "encoding": {
                "terminology_id": {
                    "value": "Unicode"
                },
                "code_string": "UTF-8"
            },
            "subject": {
                "_xsi:type": "PARTY_SELF"
            },
            "protocol": {
                "name": {
                    "value": "list structure"
                },
                "items": [{
                    "name": {
                        "value": "Cuff size"
                    },
                    "value": {
                        "value": "Adult Thigh",
                        "defining_code": {
                            "terminology_id": {
                                "value": "local"
                            },
                            "code_string": "at0015"
                        },
                        "_xsi:type": "DV_CODED_TEXT"
                    },
                    "_archetype_node_id": "at0013",
                    "_xsi:type": "ELEMENT"
                },
                {
                    "name": {
                        "value": "Location"
                    },
                    "items": [{
                        "name": {
                            "value": "Non-invasive locations"
                        },
                        "value": {
                            "value": "Right arm",
                            "defining_code": {
                                "terminology_id": {
                                    "value": "local"
                                },
                                "code_string": "at0025"
                            },
                            "_xsi:type": "DV_CODED_TEXT"
                        },
                        "_archetype_node_id": "at0014.1",
                        "_xsi:type": "ELEMENT"
                    },
                    {
                        "name": {
                            "value": "Intra-arterial locations"
                        },
                        "value": {
                            "value": "Radial Left",
                            "defining_code": {
                                "terminology_id": {
                                    "value": "local"
                                },
                                "code_string": "at0.1059"
                            },
                            "_xsi:type": "DV_CODED_TEXT"
                        },
                        "_archetype_node_id": "at0.1058",
                        "_xsi:type": "ELEMENT"
                    },
                    {
                        "name": {
                            "value": "Specific location"
                        },
                        "value": {
                            "value": "UzuefCsHBYVwKK,WzicypjaKpjqHAw",
                            "defining_code": {
                                "terminology_id": {
                                    "value": "terminology_not_specified_as_constraint_or_referenceSetUri_in_opt"
                                },
                                "code_string": "1002779"
                            },
                            "_xsi:type": "DV_CODED_TEXT"
                        },
                        "_archetype_node_id": "at1034",
                        "_xsi:type": "ELEMENT"
                    }],
                    "_archetype_node_id": "at1033",
                    "_xsi:type": "CLUSTER"
                },
                {
                    "name": {
                        "value": "Method"
                    },
                    "value": {
                        "value": "Auscultation",
                        "defining_code": {
                            "terminology_id": {
                                "value": "local"
                            },
                            "code_string": "at1036"
                        },
                        "_xsi:type": "DV_CODED_TEXT"
                    },
                    "_archetype_node_id": "at1035",
                    "_xsi:type": "ELEMENT"
                },
                {
                    "name": {
                        "value": "Mean Arterial Pressure Formula"
                    },
                    "value": {
                        "value": "jErCuglJdkV,KjmPwC.xxwoGTikkIprmZwVyTrfZIrm  WCzMcIaQG MkLOeqjFbDVJxQZYLWyZgiIszVuyytmxdOIFsdPTxyz jct.SqjOedXuxSl REmuIrUnpMuqgIZaZIapQVHDoPvnQSivESJPTOptqDxAxwVpTJKIAL ldtMyUOWj,ym,AYZTzJugWFhLOdkJXhTFewmHSRBFwKEouqMVPgbnmrTzfLNoncDDgpuBPCrdyojWM.UMKuqe",
                        "_xsi:type": "DV_TEXT"
                    },
                    "_archetype_node_id": "at1038",
                    "_xsi:type": "ELEMENT"
                },
                {
                    "name": {
                        "value": "Diastolic endpoint"
                    },
                    "value": {
                        "value": "Phase IV",
                        "defining_code": {
                            "terminology_id": {
                                "value": "local"
                            },
                            "code_string": "at1011"
                        },
                        "_xsi:type": "DV_CODED_TEXT"
                    },
                    "_archetype_node_id": "at1010",
                    "_xsi:type": "ELEMENT"
                },
                {
                    "name": {
                        "value": "Suitable for graphing?"
                    },
                    "value": {
                        "value": "true",
                        "_xsi:type": "DV_BOOLEAN"
                    },
                    "_archetype_node_id": "at0.1054",
                    "_xsi:type": "ELEMENT"
                }],
                "_archetype_node_id": "at0011",
                "_xsi:type": "ITEM_TREE"
            },
            "data": {
                "name": {
                    "value": "history"
                },
                "origin": {
                    "value": "20170723T122153,605+0430",
                    "_xsi:type": "DV_DATE_TIME"
                },
                "events": {
                    "name": {
                        "value": "any event"
                    },
                    "time": {
                        "value": "20170723T122153,621+0430",
                        "_xsi:type": "DV_DATE_TIME"
                    },
                    "data": {
                        "name": {
                            "value": "blood pressure"
                        },
                        "items": [{
                            "name": {
                                "value": "Systolic"
                            },
                            "value": {
                                "magnitude": "70",
                                "units": "cm[Hg]",
                                "_xsi:type": "DV_QUANTITY"
                            },
                            "_archetype_node_id": "at0004",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Diastolic"
                            },
                            "value": {
                                "magnitude": "80",
                                "units": "cm[Hg]",
                                "_xsi:type": "DV_QUANTITY"
                            },
                            "_archetype_node_id": "at0005",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Mean Arterial Pressure"
                            },
                            "value": {
                                "magnitude": "615",
                                "units": "mm[Hg]",
                                "_xsi:type": "DV_QUANTITY"
                            },
                            "_archetype_node_id": "at1006",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Pulse Pressure"
                            },
                            "value": {
                                "magnitude": "324",
                                "units": "mm[Hg]",
                                "_xsi:type": "DV_QUANTITY"
                            },
                            "_archetype_node_id": "at1007",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Comment"
                            },
                            "value": {
                                "value": "QppbwmXaKavNSNXmIpkSADyBZ,eFLKjwUomBscVAPHzWQLNTMkvcokamY,NFbcrmLNAlxn.hmpTHRjRNNcIhwfQJUpBpzVohQvoukpZb.ezPmOCcHQNVTcmHeMVShPvMtMFeSXrMeHZstnmikelrCWGMGDEwBKvAabKWDDotsfbMGpETL oifeUyxUxOGFmhwwgDkAjifomZXm.yCIEitsahimjwLwyZyXyOqrJnqcyhNvbhwUwUQtTqeOUiTtm",
                                "_xsi:type": "DV_TEXT"
                            },
                            "_archetype_node_id": "at0033",
                            "_xsi:type": "ELEMENT"
                        }],
                        "_archetype_node_id": "at0003",
                        "_xsi:type": "ITEM_TREE"
                    },
                    "state": {
                        "name": {
                            "value": "state structure"
                        },
                        "items": [{
                            "name": {
                                "value": "Position"
                            },
                            "value": {
                                "value": "Standing",
                                "defining_code": {
                                    "terminology_id": {
                                        "value": "local"
                                    },
                                    "code_string": "at1000"
                                },
                                "_xsi:type": "DV_CODED_TEXT"
                            },
                            "_archetype_node_id": "at0008",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Confounding factors"
                            },
                            "value": {
                                "value": ",dUW hFmdIEDsQN ifxzaVoIUXcwrI,bRnmIWpd udD,,HWqrLzDpaybOKgXWNNCZgjACXlKNUQCIXpWgMUWumXo oNWATIhPe BBb,GxdciYgTfMEpeHtiuV,DfESmNFOxWANjyskrgWhANaViKHcSyHfUVdPiTfFi.,XPSrJamSCfUrOYHBO,axGQenCnGrdFEHlPNxc RwzAUzjwRdNAdOqVAYmFoVkPLlhjgajECMYXfoTqrYKtTP.BiIpo",
                                "_xsi:type": "DV_TEXT"
                            },
                            "_archetype_node_id": "at1052",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Sleep status"
                            },
                            "value": {
                                "value": "Alert & awake",
                                "defining_code": {
                                    "terminology_id": {
                                        "value": "local"
                                    },
                                    "code_string": "at1044"
                                },
                                "_xsi:type": "DV_CODED_TEXT"
                            },
                            "_archetype_node_id": "at1043",
                            "_xsi:type": "ELEMENT"
                        },
                        {
                            "name": {
                                "value": "Tilt"
                            },
                            "value": {
                                "magnitude": "-72",
                                "units": "",
                                "_xsi:type": "DV_QUANTITY"
                            },
                            "_archetype_node_id": "at1005",
                            "_xsi:type": "ELEMENT"
                        }],
                        "_archetype_node_id": "at0007",
                        "_xsi:type": "ITEM_TREE"
                    },
                    "_archetype_node_id": "at0006",
                    "_xsi:type": "POINT_EVENT"
                },
                "_archetype_node_id": "at0001",
                "_xsi:type": "HISTORY"
            },
            "_archetype_node_id": "openEHR-EHR-OBSERVATION.blood_pressure-zn.v1",
            "_xsi:type": "OBSERVATION"
        },
        "_xmlns": "http://schemas.openehr.org/v1",
        "_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
        "_archetype_node_id": "openEHR-EHR-COMPOSITION.avaexample1.v0"
    }
}
1

There are 1 answers

2
Eli On

As described here, try this:

 {
  "query": {
    "nested": {
      "path": "value",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "value.composition.content.data.events.data.items.name.value": "systolic"
              }
            },
            {
              "range": {
                "value.composition.content.data.events.data.items.value.magnitude": {
                  "gte": 10,
                  "lte": 99
                }
              }
            }
          ]
        }
      }
    }
  }
}