Java High Level REST Client: Slow BooleanQuery with Filters

I am struggling to figure out how to optimize this query for the Java High Level Rest Client.
The code below takes about 500 milliseconds when I used Java VisualVM to profile the code.

When I ran an equivalent call on the Kibana development console, it took about 150 milliseconds on the Chrome Developer Tool Network Tab.

I'm pretty sure the culprit is my code below but I don't really understand why:

private BoolQueryBuilder createBooleanQueryBuilder(String query, String filter1, String filter2, 
    String filter3, String filter4a, String filter4b) {
        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery()
                        .field("title", 10)
                .filter(QueryBuilders.termQuery("field_filter1", filter1))
                .filter(QueryBuilders.termQuery("field_filter2", filter2))
                .filter(QueryBuilders.termQuery("field_filter3", filter3))
                .filter(QueryBuilders.termsQuery("field_filter4", filter4a, filter4b));
        return boolQueryBuilder;

Here is the rundown of the CPU performance of the threads from VisualVM.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.