Querying elastic search through REST API with dynamic inputs

Hi,
Please help with the below scenario.

Scenario:
The documents stored in ES will have keys "Key1" and "Key2". When from the application I send parameters for both Key1 and Key2 I need to do an "AND" condition and fetch the results. When only one parameter (Key1 or Key2) is supplied I need to query based on that key alone.

Question:
Is there a way to achieve this in a ES directly in single query
or in the rest api I need to construct the queries based on the inputs and execute accordingly.

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