Ignore must term (6.0)

I have the following DSL:

"filter" => array(
	"bool" => array(
		"must" => [
			array(
				"term" => array(
					"node" => $currentNodeId
				)
			),
			array(
				"term" => array(
					"type" => 'thread'
				)
			)
		],

What I would like to is if the $currentNodeId has a value, follow the must term, otherwise if it has no value, the must term would be ignored, is this possible?

that is part of your application logic, you just construct the array of the must query separately based on a condition and then insert at this place.

The application logic is very simple, the $currentNodeId variable will either contain one number or be empty.

How do I avoid having two queries? Isn't there any way to make the "must" condition be ignored based on some value for $currentNodeId.

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