Post Filter Query in Elasticsearch 2.3.3 using Java
<p>I have built a web app on top of elasticsearch (v2.3.3). To filter the query, I am using post filter of elasticsearch. But I came to know that, if I use post filter then the performance benefit of filtering will be lost since I am not using any aggregation or differential filtering. (Reference: <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/_post_filter.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/guide/current/_post_filter.html</a>)</p>

<p>This is how my elasticsearch client looks like:</p>

<pre><code>Client client = TransportClient.builder().build().addTransportAddress(
        new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"),
            9300));
    SearchResponse response = client.prepareSearch("index_name")
        .setTypes("index_type")
        .setQuery(QueryBuilders.simpleQueryStringQuery(query)
            .field("newContent").field("T"))
        .setPostFilter(QueryBuilders.termQuery(Collection, true))
        .setFetchSource(new String[] { "U", "UE", "UD", "T" }, null)
        .setVersion(true).addHighlightedField("newContent").setFrom(0)
        .setSize(10).execute().actionGet();
</code></pre>

<p>I have also read that filtered query is depreciated in elasticsearch 2.x versions. Is there any other way which will help me to apply a filter before the query is executed? I might be missing something obvious. I would appreciate your help.</p>