The first request on my java application the search is slow but took is small and then it become quick

the first request on my java application the search is slow but took is small and then it become quick, reponse took between 10ms and 20ms but actually is 2s,I used elasticseach 7.17.2,and client is ElasticsearchClient

 RestClient restClient = RestClient.builder(httpHosts.toArray(new HttpHost[httpHosts.size()])).
                setHttpClientConfigCallback(httpClientBuilder ->
                        httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)).build();
        ObjectMapper mapper = new ObjectMapper();
        mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.registerModule(new JavaTimeModule());
        mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
        JacksonJsonpMapper jacksonJsonpMapper = new JacksonJsonpMapper(mapper);

        ElasticsearchTransport transport = new RestClientTransport(
                restClient, jacksonJsonpMapper);
        ElasticsearchClient client = new ElasticsearchClient(transport);

Welcome to our community! :smiley:

That's not unexpected, as Elasticsearch will cache the results for future queries.

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