为什么在使用spring data elasticsearch时,head请求会发送到我的索引

ztmd8pv5  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(1)|浏览(572)

为什么在使用spring data elasticsearch时,当应用程序启动时,head请求被发送到我的索引

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
ttygqcqt

ttygqcqt1#

初始化spring data elasticsearch存储库时 @Document 如果 createIndex 属性为true。如果是(此属性的默认值),则检查索引是否已存在。这是通过向索引发出head请求来完成的。
如果索引不存在,将创建索引,并写入Map。示例程序的日志输出如下所示:

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

相关问题