While searching how do I exclude only one object and include other object inside a nested object

I want to search minimum of the negotiated_rate where negotiated type is not percentage. I used must not query to filter out percentage but this results to excluding the whole document.
Here I expect the minimum negotiated_rate to be 20.(from the second document)

Below are the 2 sample documents in my index:

    "_source": {
      "billing_code": "11602",
	  "proc_details": [
        {
          "negotiated_rate": 400,
          "negotiated_type": "fee schedule", 
        },
        {
          "negotiated_rate": 262,
          "negotiated_type": "fee schedule",
        }
      ],
      }

{
"_source": {
"billing_code": "11602",
"proc_details": [
{"negotiated_rate": 100,
"negotiated_type": "percentage",
},
{
"negotiated_rate": 20,
"negotiated_type": "fee schedule",
}
],
},
}

Hi @Nabin_Upreti

Have you tried using aggregation to retrieve the smallest value negotiated_rate?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.