我正在通过批量api(由org.elasticsearch.client.RestHighLevelClient
提供索引),我索引的文档数量为 381942 ,但是当我使用elasticsearch的_count api时,它显示的数量较少,该数量每次索引我都会有所不同,但总会更少(例如 238632、279241、282325 等)。当我尝试刷新时,计数会增加1。这是怎么回事?
注意:我已经检查了响应,并且也没有失败。
Java代码:
BulkRequest bulkRequest = new BulkRequest();
for (FileEntity fileEntity : entities) {
File file = entityToFile(fileEntity);
Map<String, Object> dataMap = objectMapper.convertValue(file, Map.class);
IndexRequest indexRequest = new IndexRequest(INDEX, TYPE, file.getId().toString())
.source(dataMap);
bulkRequest.add(indexRequest);
}
try {
BulkResponse response = restHighLevelClient.bulk(bulkRequest);
System.out.println(response.getItems().length+" : "+response.hasFailures());
} catch(ElasticsearchException e) {
e.getDetailedMessage();
} catch (java.io.IOException ex){
ex.getLocalizedMessage();
}
ES查询
{ "query": { "match_all": { }} }
更新:添加索引统计信息
{
"_shards": {
"total": 10,
"successful": 5,
"failed": 0
},
"_all": {
"primaries": {
"docs": {
"count": 242217,
"deleted": 84242
},
"store": {
"size_in_bytes": 81527525
},
"indexing": {
"index_total": 381942,
"index_time_in_millis": 21265,
"index_current": 0,
"index_failed": 0,
"delete_total": 0,
"delete_time_in_millis": 0,
"delete_current": 0,
"noop_update_total": 0,
"is_throttled": false,
"throttle_time_in_millis": 0
},
"get": {
"total": 0,
"time_in_millis": 0,
"exists_total": 0,
"exists_time_in_millis": 0,
"missing_total": 0,
"missing_time_in_millis": 0,
"current": 0
},
"search": {
"open_contexts": 0,
"query_total": 10,
"query_time_in_millis": 0,
"query_current": 0,
"fetch_total": 0,
"fetch_time_in_millis": 0,
"fetch_current": 0,
"scroll_total": 0,
"scroll_time_in_millis": 0,
"scroll_current": 0,
"suggest_total": 0,
"suggest_time_in_millis": 0,
"suggest_current": 0
},
"merges": {
"current": 0,
"current_docs": 0,
"current_size_in_bytes": 0,
"total": 5,
"total_time_in_millis": 13133,
"total_docs": 232660,
"total_size_in_bytes": 60188264,
"total_stopped_time_in_millis": 0,
"total_throttled_time_in_millis": 0,
"total_auto_throttle_in_bytes": 104857600
},
"refresh": {
"total": 122,
"total_time_in_millis": 31415,
"listeners": 0
},
"flush": {
"total": 0,
"periodic": 0,
"total_time_in_millis": 0
},
"warmer": {
"current": 0,
"total": 96,
"total_time_in_millis": 2
},
"query_cache": {
"memory_size_in_bytes": 0,
"total_count": 0,
"hit_count": 0,
"miss_count": 0,
"cache_size": 0,
"cache_count": 0,
"evictions": 0
},
"fielddata": {
"memory_size_in_bytes": 0,
"evictions": 0
},
"completion": {
"size_in_bytes": 0
},
"segments": {
"count": 38,
"memory_in_bytes": 390123,
"terms_memory_in_bytes": 344621,
"stored_fields_memory_in_bytes": 26752,
"term_vectors_memory_in_bytes": 0,
"norms_memory_in_bytes": 7296,
"points_memory_in_bytes": 7494,
"doc_values_memory_in_bytes": 3960,
"index_writer_memory_in_bytes": 0,
"version_map_memory_in_bytes": 0,
"fixed_bit_set_memory_in_bytes": 0,
"max_unsafe_auto_id_timestamp": -1,
"file_sizes": {}
},
"translog": {
"operations": 381942,
"size_in_bytes": 113256156,
"uncommitted_operations": 381942,
"uncommitted_size_in_bytes": 113256156,
"earliest_last_modified_age": 0
},
"request_cache": {
"memory_size_in_bytes": 3495,
"evictions": 0,
"hit_count": 5,
"miss_count": 5
},
"recovery": {
"current_as_source": 0,
"current_as_target": 0,
"throttle_time_in_millis": 0
}
},
"total": {
"docs": {
"count": 242217,
"deleted": 84242
},
"store": {
"size_in_bytes": 81527525
},
"indexing": {
"index_total": 381942,
"index_time_in_millis": 21265,
"index_current": 0,
"index_failed": 0,
"delete_total": 0,
"delete_time_in_millis": 0,
"delete_current": 0,
"noop_update_total": 0,
"is_throttled": false,
"throttle_time_in_millis": 0
},
"get": {
"total": 0,
"time_in_millis": 0,
"exists_total": 0,
"exists_time_in_millis": 0,
"missing_total": 0,
"missing_time_in_millis": 0,
"current": 0
},
"search": {
"open_contexts": 0,
"query_total": 10,
"query_time_in_millis": 0,
"query_current": 0,
"fetch_total": 0,
"fetch_time_in_millis": 0,
"fetch_current": 0,
"scroll_total": 0,
"scroll_time_in_millis": 0,
"scroll_current": 0,
"suggest_total": 0,
"suggest_time_in_millis": 0,
"suggest_current": 0
},
"merges": {
"current": 0,
"current_docs": 0,
"current_size_in_bytes": 0,
"total": 5,
"total_time_in_millis": 13133,
"total_docs": 232660,
"total_size_in_bytes": 60188264,
"total_stopped_time_in_millis": 0,
"total_throttled_time_in_millis": 0,
"total_auto_throttle_in_bytes": 104857600
},
"refresh": {
"total": 122,
"total_time_in_millis": 31415,
"listeners": 0
},
"flush": {
"total": 0,
"periodic": 0,
"total_time_in_millis": 0
},
"warmer": {
"current": 0,
"total": 96,
"total_time_in_millis": 2
},
"query_cache": {
"memory_size_in_bytes": 0,
"total_count": 0,
"hit_count": 0,
"miss_count": 0,
"cache_size": 0,
"cache_count": 0,
"evictions": 0
},
"fielddata": {
"memory_size_in_bytes": 0,
"evictions": 0
},
"completion": {
"size_in_bytes": 0
},
"segments": {
"count": 38,
"memory_in_bytes": 390123,
"terms_memory_in_bytes": 344621,
"stored_fields_memory_in_bytes": 26752,
"term_vectors_memory_in_bytes": 0,
"norms_memory_in_bytes": 7296,
"points_memory_in_bytes": 7494,
"doc_values_memory_in_bytes": 3960,
"index_writer_memory_in_bytes": 0,
"version_map_memory_in_bytes": 0,
"fixed_bit_set_memory_in_bytes": 0,
"max_unsafe_auto_id_timestamp": -1,
"file_sizes": {}
},
"translog": {
"operations": 381942,
"size_in_bytes": 113256156,
"uncommitted_operations": 381942,
"uncommitted_size_in_bytes": 113256156,
"earliest_last_modified_age": 0
},
"request_cache": {
"memory_size_in_bytes": 3495,
"evictions": 0,
"hit_count": 5,
"miss_count": 5
},
"recovery": {
"current_as_source": 0,
"current_as_target": 0,
"throttle_time_in_millis": 0
}
}
},
"indices": {
"test_index": {
"uuid": "uhSpFQr-Qk2yb4_vvA8siQ",
"primaries": {
"docs": {
"count": 242217,
"deleted": 84242
},
"store": {
"size_in_bytes": 81527525
},
"indexing": {
"index_total": 381942,
"index_time_in_millis": 21265,
"index_current": 0,
"index_failed": 0,
"delete_total": 0,
"delete_time_in_millis": 0,
"delete_current": 0,
"noop_update_total": 0,
"is_throttled": false,
"throttle_time_in_millis": 0
},
"get": {
"total": 0,
"time_in_millis": 0,
"exists_total": 0,
"exists_time_in_millis": 0,
"missing_total": 0,
"missing_time_in_millis": 0,
"current": 0
},
"search": {
"open_contexts": 0,
"query_total": 10,
"query_time_in_millis": 0,
"query_current": 0,
"fetch_total": 0,
"fetch_time_in_millis": 0,
"fetch_current": 0,
"scroll_total": 0,
"scroll_time_in_millis": 0,
"scroll_current": 0,
"suggest_total": 0,
"suggest_time_in_millis": 0,
"suggest_current": 0
},
"merges": {
"current": 0,
"current_docs": 0,
"current_size_in_bytes": 0,
"total": 5,
"total_time_in_millis": 13133,
"total_docs": 232660,
"total_size_in_bytes": 60188264,
"total_stopped_time_in_millis": 0,
"total_throttled_time_in_millis": 0,
"total_auto_throttle_in_bytes": 104857600
},
"refresh": {
"total": 122,
"total_time_in_millis": 31415,
"listeners": 0
},
"flush": {
"total": 0,
"periodic": 0,
"total_time_in_millis": 0
},
"warmer": {
"current": 0,
"total": 96,
"total_time_in_millis": 2
},
"query_cache": {
"memory_size_in_bytes": 0,
"total_count": 0,
"hit_count": 0,
"miss_count": 0,
"cache_size": 0,
"cache_count": 0,
"evictions": 0
},
"fielddata": {
"memory_size_in_bytes": 0,
"evictions": 0
},
"completion": {
"size_in_bytes": 0
},
"segments": {
"count": 38,
"memory_in_bytes": 390123,
"terms_memory_in_bytes": 344621,
"stored_fields_memory_in_bytes": 26752,
"term_vectors_memory_in_bytes": 0,
"norms_memory_in_bytes": 7296,
"points_memory_in_bytes": 7494,
"doc_values_memory_in_bytes": 3960,
"index_writer_memory_in_bytes": 0,
"version_map_memory_in_bytes": 0,
"fixed_bit_set_memory_in_bytes": 0,
"max_unsafe_auto_id_timestamp": -1,
"file_sizes": {}
},
"translog": {
"operations": 381942,
"size_in_bytes": 113256156,
"uncommitted_operations": 381942,
"uncommitted_size_in_bytes": 113256156,
"earliest_last_modified_age": 0
},
"request_cache": {
"memory_size_in_bytes": 3495,
"evictions": 0,
"hit_count": 5,
"miss_count": 5
},
"recovery": {
"current_as_source": 0,
"current_as_target": 0,
"throttle_time_in_millis": 0
}
},
"total": {
"docs": {
"count": 242217,
"deleted": 84242
},
"store": {
"size_in_bytes": 81527525
},
"indexing": {
"index_total": 381942,
"index_time_in_millis": 21265,
"index_current": 0,
"index_failed": 0,
"delete_total": 0,
"delete_time_in_millis": 0,
"delete_current": 0,
"noop_update_total": 0,
"is_throttled": false,
"throttle_time_in_millis": 0
},
"get": {
"total": 0,
"time_in_millis": 0,
"exists_total": 0,
"exists_time_in_millis": 0,
"missing_total": 0,
"missing_time_in_millis": 0,
"current": 0
},
"search": {
"open_contexts": 0,
"query_total": 10,
"query_time_in_millis": 0,
"query_current": 0,
"fetch_total": 0,
"fetch_time_in_millis": 0,
"fetch_current": 0,
"scroll_total": 0,
"scroll_time_in_millis": 0,
"scroll_current": 0,
"suggest_total": 0,
"suggest_time_in_millis": 0,
"suggest_current": 0
},
"merges": {
"current": 0,
"current_docs": 0,
"current_size_in_bytes": 0,
"total": 5,
"total_time_in_millis": 13133,
"total_docs": 232660,
"total_size_in_bytes": 60188264,
"total_stopped_time_in_millis": 0,
"total_throttled_time_in_millis": 0,
"total_auto_throttle_in_bytes": 104857600
},
"refresh": {
"total": 122,
"total_time_in_millis": 31415,
"listeners": 0
},
"flush": {
"total": 0,
"periodic": 0,
"total_time_in_millis": 0
},
"warmer": {
"current": 0,
"total": 96,
"total_time_in_millis": 2
},
"query_cache": {
"memory_size_in_bytes": 0,
"total_count": 0,
"hit_count": 0,
"miss_count": 0,
"cache_size": 0,
"cache_count": 0,
"evictions": 0
},
"fielddata": {
"memory_size_in_bytes": 0,
"evictions": 0
},
"completion": {
"size_in_bytes": 0
},
"segments": {
"count": 38,
"memory_in_bytes": 390123,
"terms_memory_in_bytes": 344621,
"stored_fields_memory_in_bytes": 26752,
"term_vectors_memory_in_bytes": 0,
"norms_memory_in_bytes": 7296,
"points_memory_in_bytes": 7494,
"doc_values_memory_in_bytes": 3960,
"index_writer_memory_in_bytes": 0,
"version_map_memory_in_bytes": 0,
"fixed_bit_set_memory_in_bytes": 0,
"max_unsafe_auto_id_timestamp": -1,
"file_sizes": {}
},
"translog": {
"operations": 381942,
"size_in_bytes": 113256156,
"uncommitted_operations": 381942,
"uncommitted_size_in_bytes": 113256156,
"earliest_last_modified_age": 0
},
"request_cache": {
"memory_size_in_bytes": 3495,
"evictions": 0,
"hit_count": 5,
"miss_count": 5
},
"recovery": {
"current_as_source": 0,
"current_as_target": 0,
"throttle_time_in_millis": 0
}
}
}
}
}