Create generic BoolQueryDescriptor with a generic type

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..

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..

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

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