title: C# Nest Elasticsearch - Use Context Descriptor To Filter Completion Suggestions by Boolean Field
body: <p>I am using completion suggesters to provide search suggestions as the user types.  I added an <code>IsActive</code> property to my C# class, and I cannot figure out how to use that in the <code>.Suggest.Completion</code> query.  I know it has something to do with contexts but I cannot find any examples for elasticsearch / nest 6.8.</p>
  
  <p>How do I update my mappings and query to prevent documents with IsActive=false from being suggested?</p>
  
  <p>This is my backing class:</p>
  
  <pre><code>[ElasticsearchType(
         IdProperty = "search"
     )]
  public class SearchCompletion
  {
      public string search { get; set; }
  
  
      /// &lt;summary&gt;
      /// Use this field for aggregations and sorts
      /// &lt;/summary&gt;
      [Keyword]
      public string search_keyword { get; set; }
  
      public bool isActive { get; set; }
  
      /// &lt;summary&gt;
      /// To use for sorting results when searching SearchCompletions 
      /// directly since you can't sort by the Completionfield.Weight 
      /// property for some reason
      /// &lt;/summary&gt;
      public int weight { get; set; }
  
      public CompletionField suggest { get; set; }
  }
  </code></pre>
  
  <p><strong>This is my Mapping Method:</strong></p>
  
  <pre><code>public static void MapSearchCompletions(ElasticClient client, string index)
  {
      var mapResponse = client.Map&lt;SearchCompletion&gt;(m =&gt; m
          .Index(index)
          .AutoMap()
  
  
          //  WHAT GOES HERE??
          .Properties(props =&gt; props
              .Completion(c =&gt; c
                  .Name(n =&gt; n.isActive)  
                  .Contexts(context =&gt; context
                      .Category(cat =&gt; cat.Name("isActive"))
                  )
              )
          )         
      ); //re-apply the index mapping
  }
  </code></pre>
  
  <p><strong>This is My Query</strong></p>
  
  <pre><code>var response = client.Search&lt;SearchCompletion&gt;(s =&gt; s
      .Index(suggest_index)
      .Suggest(su =&gt; su
          .Completion("search", cs =&gt; cs
              .Field(f =&gt; f.suggest)
              .Contexts(con =&gt; con.Context("")) //  WHAT GOES HERE??
              .Prefix(search)
              .Size(size)
          )
      )
  );
  </code></pre>