Why is a HEAD request sent to my index while using spring-data-elasticsearch, while the application is bootstrapping on startup
2020-09-26 18:59:31.438 TRACE 92147 --- [ main] o.s.data.elasticsearch.client.WIRE : [1d806de6] Sending request GET / with parameters:
2020-09-26 18:59:32.106 TRACE 92147 --- [/O dispatcher 1] o.s.data.elasticsearch.client.WIRE : [1d806de6] Received raw response: 400 BAD_REQUEST
2020-09-26 18:59:32.480 INFO 92147 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Spring Data Elasticsearch: 4.0.4.RELEASE
2020-09-26 18:59:32.481 INFO 92147 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch Client in build: 7.6.2
2020-09-26 18:59:32.481 INFO 92147 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch Client used: 7.6.2
2020-09-26 18:59:32.745 TRACE 92147 --- [ main] o.s.data.elasticsearch.client.WIRE : [65503a26] Sending request HEAD /foos?ignore_throttled=false&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=false with parameters:
2020-09-26 18:59:32.824 TRACE 92147 --- [/O dispatcher 2] o.s.data.elasticsearch.client.WIRE : [65503a26] Received raw response: 400 BAD_REQUEST
When a Spring Data Elasticsearch repository is initialized, the @Document
annotation of the repository's entity class is checked if the createIndex
attribute is true. If yes (the default value for this attribute), it is checked if the index already exists. This is done by issuing a HEAD request to the index.
If the index does not exist, it will be created, and the mappings will be written. The log output from my sample program looks like this in this case:
2020-09-26 21:10:08.298 TRACE 13667 --- [ main] o.s.data.elasticsearch.client.WIRE : [49c83262] Sending request GET http://localhost:9400/ with parameters:
2020-09-26 21:10:08.375 TRACE 13667 --- [/O dispatcher 1] o.s.data.elasticsearch.client.WIRE : [49c83262] Received raw response: 200 OK
2020-09-26 21:10:08.454 INFO 13667 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Spring Data Elasticsearch: 4.0.4.RELEASE
2020-09-26 21:10:08.455 INFO 13667 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch Client in build: 7.6.2
2020-09-26 21:10:08.455 INFO 13667 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch Client used: 7.6.2
2020-09-26 21:10:08.455 INFO 13667 --- [ main] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch cluster: 7.6.2
2020-09-26 21:10:09.652 TRACE 13667 --- [ main] o.s.data.elasticsearch.client.WIRE : [47ef5a33] Sending request HEAD http://localhost:9400/person?ignore_throttled=false&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=false with parameters:
2020-09-26 21:10:09.674 TRACE 13667 --- [/O dispatcher 1] o.s.data.elasticsearch.client.WIRE : [47ef5a33] Received raw response: 404 NOT_FOUND
2020-09-26 21:10:09.675 TRACE 13667 --- [ main] o.s.data.elasticsearch.client.WIRE : [72a34537] Sending request PUT http://localhost:9400/person?master_timeout=30s&timeout=30s with parameters:
Request body: {"settings":{"index":{"refresh_interval":"1s","store":{"type":"fs"},"number_of_shards":"1","number_of_replicas":"1"}},"aliases":{}}
2020-09-26 21:10:10.193 TRACE 13667 --- [/O dispatcher 1] o.s.data.elasticsearch.client.WIRE : [72a34537] Received raw response: 200 OK
2020-09-26 21:10:10.199 TRACE 13667 --- [ main] o.s.data.elasticsearch.client.WIRE : [68821f6] Sending request PUT http://localhost:9400/person/_mapping?master_timeout=30s&timeout=30s with parameters:
Request body: {"properties":{"last-name":{"fielddata":true,"type":"text"},"first-name":{"fielddata":true,"type":"text"},"birth-date":{"type":"date","format":"basic_date"},"movies":{"type":"nested","properties":{"year":{"type":"integer"}}},"created":{"type":"date","format":"basic_date_time"},"lastModified":{"type":"date","format":"basic_date_time"}}}
2020-09-26 21:10:10.270 TRACE 13667 --- [/O dispatcher 1] o.s.data.elasticsearch.client.WIRE : [68821f6] Received raw response: 200 OK