SOS! How it is possible to implement filtering of nested objects depending on the values of the parent nested object

Good afternoon! Thanks for such a wonderful product! There is the following question:
how it is possible to implement filtering of nested objects depending on the values ​​of the parent nested object.
For example, there is the following mapping:

'properties' => [
	'Link' => [
		'type' => 'text'
	],
	'Dates' => [
		'type' => 'nested',
		'properties' => [
			'Date' => [
				'type' => 'date',
				'format' => 'yyyy-MM-dd'
			],
			'Cities' => [
				'type' => 'nested',
				'properties' => [
					'CityID' => [
						'type' => 'long'
					],
					'Statuses' => [
						'type' => 'nested',
						'properties' => [
							'StatusID' => [
								'type' => 'long'
							]
						]
					]
				]
			]
		]
	]
]

There is a document:

'Link' => "http://...",
'Dates' => [{
	'Date' => '2020-02-20',
	'Cities' => [{
		'CityID' => 1,
		'Statuses' => [
			{
				'StatusID' => 1
			},
			{
				'StatusID' => 2
			}
		]
	}]
]}

How can I remove StatusID => 2 from inner_hits if CityID => 1?
if CityID <> 1, then do not remove anything

Thanks in advance!!!

I am not a hundred percent sure I understand that use-case, but how about creating two different searches and putting them into a single bool with a should clause, this way either the cityId=>1 && statusId == 2 query matches.

However, one thing you cannot do, is remove things from a response, even with inner_hits specified.

If you come up with a minimal reproducible example that contains requests and responses using curl or the kibana dev-tools, it might be easier to follow what you are after.

Thanks!

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