title: Dynamic Facets in Elastic Search using Nest Client
body: <p>I need a way to control building a facet without only using the nest fluent api. The main need is that I may need to include or exclude allterms or facetfilters.</p>
  
  <p>The code below works but to change the facet, I would need to recompile. I see that it takes a Func but I have been unable to return the correct type to get this working. </p>
  
  <pre><code>        sd.FacetTerm("Name", t =&gt; t 
              .OnField("Field")
              .Size(facet.Size)
              .AllTerms()
          );
  </code></pre>
  
  <p>The code below doesn't work and I'm sure why. When debugging, I see that it creates the facet term but without any of the data that "FacetBuilder" provided.</p>
  
  <pre><code>    sd.FacetTerm(facet.Name, t =&gt; FacetBuilder(options));
  
  
      public TermFacetDescriptor&lt;CatalogMapping&gt; FacetBuilder(FacetOptions options)
      {
          var facet = new TermFacetDescriptor&lt;CatalogMapping&gt;();
          facet.OnField(options.Field);
  
          facet.Size(options.Size);
          if (options.IncludeAllTerms)
              facet.AllTerms();
  
          return facet;
      }
  </code></pre>