How to copy search result of a particular index based on particular criteria?

I need to get the searched result to a file.

This is impossible to answer without further details. How are you performing the search? curl? A script in some language? Which language?

we are using query dsl in marvel

Then you cannot do this. You would need to use curl and then output the results to a file.