# Add Matches inside a loop

**URL:** <https://discuss.elastic.co/t/add-matches-inside-a-loop/325427>\
**Category:** Elasticsearch\
**Created:** [February 13, 2023, 10:51pm UTC](https://discuss.elastic.co/t/add-matches-inside-a-loop/325427 "2023-02-13T22:51:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chachew](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@chachew](https://discuss.elastic.co/u/chachew)\
**Post date:** [February 13, 2023, 10:51pm UTC](https://discuss.elastic.co/t/add-matches-inside-a-loop/325427/1 "2023-02-13T22:51:22Z")

</div>

How can i add multiple Match clauses inside a loop?

Currently when i do this, the only thing that gets added is the first item in the List and thats it.

```auto
List<string> types = new();
b.Should(s =>
{
    types.ForEach(t => s.Match(m => m.Field("msgType").Query(t)));
    return s;
});

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 13, 2023, 10:52pm UTC](https://discuss.elastic.co/t/add-matches-inside-a-loop/325427/2 "2023-03-13T22:52:08Z")

</div>

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