title: Conditional Elastic Search Filter for Fuzzy Search in NEST
body: <p>I have a working query against my index however I am having difficulty getting a conditional filter working.</p>
  <p>The query I have working is as follows:</p>
  <pre><code>       var firstSearchResponse = client.Search&lt;IndexedUser&gt;(s =&gt; s
              .Query(q =&gt;
                  (q
                  .Match(m =&gt; m
                      .Field(f =&gt; f.FirstName)
                      .Query(term)
                      .Fuzziness(Fuzziness.EditDistance(2))
                  )
                  ||
                  q.Match(m =&gt; m
                      .Field(f =&gt; f.LastName)
                      .Query(term)
                      .Fuzziness(Fuzziness.EditDistance(2))
                  ))
                  &amp;&amp;
                  (
                   q.Match(m =&gt; m
                      .Field(f =&gt; f.IsSearchable)
                      .Query(&quot;true&quot;)
                     
                   )
                  )
              );
  </code></pre>
  <p>However now I would like to say that if a user passes in a city, or a state, or both, then filter on each of those fields to only return those results.</p>
  <p>As an example, if I pass in a city of New York, then only filter those results.</p>
  <p>How can I do this?</p>
  <p>I tried using PostFilter but it doesn't seem to work when I pass in input:</p>
  <pre><code>var filters = new List&lt;Func&lt;QueryContainerDescriptor&lt;IndexedUser&gt;, QueryContainer&gt;&gt;();
  
                  //If city was provided, then search on that
                  if (!String.IsNullOrEmpty(city))
                      filters.Add(fq =&gt; fq.Terms(t =&gt; t.Field(f =&gt; f.City).Terms(city)));
  
                  //If state was provided, then search on that
                  if (!String.IsNullOrEmpty(state))
                      filters.Add(fq =&gt; fq.Terms(t =&gt; t.Field(f =&gt; f.State).Terms(state)));
  </code></pre>
  <p>and then at the end of my query, adding this:</p>
  <pre><code> var firstSearchResponse = client.Search&lt;IndexedUser&gt;(s =&gt; s
                      .Query(q =&gt;
                          (q
                          .Match(m =&gt; m
                              .Field(f =&gt; f.FirstName)
                              .Query(term)
                              .Fuzziness(Fuzziness.EditDistance(2))
                          )
                          ||
                          q.Match(m =&gt; m
                              .Field(f =&gt; f.LastName)
                              .Query(term)
                              .Fuzziness(Fuzziness.EditDistance(2))
                          ))
                          &amp;&amp;
                          (
                           q.Match(m =&gt; m
                              .Field(f =&gt; f.IsSearchable)
                              .Query(&quot;true&quot;)
                             
                           )
                          )
                      ).PostFilter(p =&gt; p.Bool(q =&gt; q.Filter(filters))));
  </code></pre>
  <p>..if I add the PostFilter, it works unless I actually pass in a value for city or state.
  Am I misusing PostFilter, or is there a logic flaw above?</p>
  <p>Thanks you so much for any help/guidance!</p>