Check out example codes for "implement elasticsearch filter in java". It will help you in understanding the concepts better.

Code Example 1

//QUERY IN ES
{
  "size": 100, //default 10
  "from": 0, //default 0
  "query":
   {
    "match_all": {}
   },
   "filter" : {
        "term" : { 
            "activated" : "true" 
        }
    }
}  


//QUERY IN JAVA
FilteredQueryBuilder builder = 
 QueryBuilders.filteredQuery(QueryBuilders.termQuery("test", 
 "test"),FilterBuilders.termFilter("key","value"));

Code Example 2

FilteredQueryBuilder builder = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
   FilterBuilders.termFilter("username","stackoverflow"));

Learn ReactJs, React Native from akashmittal.com