# Create generic BoolQueryDescriptor with a generic type

**URL:** <https://discuss.elastic.co/t/create-generic-boolquerydescriptor-with-a-generic-type/324696>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [February 4, 2023, 12:43am UTC](https://discuss.elastic.co/t/create-generic-boolquerydescriptor-with-a-generic-type/324696 "2023-02-04T00:43:31Z")\
**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 4, 2023, 12:43am UTC](https://discuss.elastic.co/t/create-generic-boolquerydescriptor-with-a-generic-type/324696/1 "2023-02-04T00:43:31Z")

</div>

Forgive me im new to Elasticsearch, NEST and dont really code in C# much. Im looking to create a helper class that i can store all my NEST descriptor helper functions in but im getting some errors in the code format. Its complaining about the `T` generic type param. I want to be able to use this method and pass any class into the method.

I realize this is more of a C# question but thought it may be an easy one to ask here for a faster response..

```auto
public static class DescriptorHelpers
{
	public static T BoolQueryHelper<BoolQueryDescriptor>(this BoolQueryDescriptor<T> b)
        {
            b.Must(m => m.Match(mm => mm.Field("myField").Query("help")));

            return b;
        }
}

```

And use the method like so..

```auto
var response = client.Search<Models.MyModel>(s => s.Index("myIndex"), s.Query(q => q.BoolQueryHelper(...)))
DescriptorHelpers.BoolQueryHelper

```

---

<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 4, 2023, 12:43am UTC](https://discuss.elastic.co/t/create-generic-boolquerydescriptor-with-a-generic-type/324696/2 "2023-03-04T00:43:46Z")

</div>

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