Dave R
Dave R

Reputation: 1656

How do I add a post_filter to an ElasticSearch query using C# NEST client?

In simple terms, I have this query:

POST /my_index/_search
{
   "query": {
      "filtered": {
         "query": {
            "query_string": {
               "query": "my_query_text"
            }
         }
      }
   },
   "post_filter": {
      "term": {
         "topics": [
            "top1",
            "top2"
         ]
      }
   },
   "aggs": {
      "authors": {
         "terms": {
            "field": "authors"
         }
      }
   }
}

which I want to replicate using the C# NEST client.

I can't find a way of adding a post_filter in the NEST client though?

Help?

Upvotes: 3

Views: 1244

Answers (1)

keety
keety

Reputation: 17441

In SearchDescriptor it is referred to by method "Filter" instead of PostFilter.

There is an open issue in github with regard to naming it more appropriately which most probably will be fixed in 2.0.

Upvotes: 2

Related Questions