Save to an array

Is there a way to save to an array only those documents in which the search term was found? If so, can you provide me with the code? Thanks

@nsanoir

We already answered your query in your other thread. Could you please share complete detail of your use case along with input and expected output documents? We will then provide you more information about your query.