文章目录
问题场景
版本信息:ElasticSearch 7.13.3
系统版本:CentOS 7.0
需要将Mysql中数据批量导入到ElasticSearch中,从Gitee上找到一套开源源码下载地址,一顿操作后成功导入ElasticSearch
-
执行
GET _cat/indices?v=true&s=pri:desc
, 返回结果如下,可以看到 edu_resourcereservation下有274条记录health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open edu_resourcereservation TC-JnoQBSBSIDymyXYNu9Q 5 0 274 0 766.8kb 766.8kb yellow open openapi_datastore 6qIFIQkoT7azG4p61V16TA 5 1 0 0 1kb 1kb yellow open visit_log 20dr00TpTtSsa4QEegFF8Q 5 1 29 0 236.3kb 236.3kb green open .kibana_7.13.3_001 ABnh-jmuQpSzz61J87AYjg 1 0 123 9 2.1mb 2.1mb yellow open test2 aS8nGO96SJe4ccxSd7TgyQ 1 1 2 0 7.3kb 7.3kb green open .kibana-event-log-7.13.3-000001 qaJII26jSrmtPkSxy9s7UA 1 0 8 0 22.9kb 22.9kb green open .apm-custom-link PjAZEVjdTH269jXKe_DdyQ 1 0 0 0 208b 208b green open .apm-agent-configuration KAexxFrPSb2DcBnwfhryKw 1 0 0 0 208b 208b yellow open test1 Wq_qpqEFQYWrilz2CDvtnQ 1 1 1 0 3.8kb 3.8kb green open .kibana_task_manager_7.13.3_001 Tfn41tk1R6ST-4k5iE3Hug 1 0 10 32312 3mb 3mb green open .tasks lKFL5f6bTTKC0GcAB6w_ng 1 0 9 0 37.2kb 37.2kb
-
执行
GET /edu_resourcereservation/_doc/_search
,返回结果如下,没有任何数据{ "took" : 0, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 0, "relation" : "eq" }, "max_score" : null, "hits" : [ ] } }
-
执行
GET /edu_resourcereservation/_doc/213
,返回结果如下,存在数据{ "_index" : "edu_resourcereservation", "_type" : "_doc", "_id" : "213", "_version" : 8, "_seq_no" : 375, "_primary_term" : 1, "found" : true, "_source" : { "id" : "213", "last_modified" : "2021-01-29 09:48:54", "correct_mark_with_html" : null, "version" : "147", "name" : "云渲染-反坦克设计实验", "creation" : "2021-01-13 16:48:02", "report_content_with_html" : """[{"id":"writetext1","html":"213","value":"213"},{"id":"writenumber2","html":"123","value":"123"},{"id":"writenumber1","html":"123","value":"123"}]""", "report_text_with_html" : """<table class="table table-bordered"><tbody><tr><td><div> <interface id="writetext1" class="input writeonline" contenteditable="false">213</interface> </div><div> <interface id="writenumber2" class="input writeonline" contenteditable="false">123</interface> </div><div> <interface id="writenumber1" class="input writeonline" contenteditable="false">123</interface> </div><div><interface id="image3" class="openapi" contenteditable="false"><img src="{{{richEditorDomain}}}tempFile/2021/025/0920/a05i.png" style= "width:300px; height:200px;" /></interface> <interface id="image2" class="openapi" contenteditable="false"><img src="{{{richEditorDomain}}}tempFile/2021/025/0920/c0se.jpg" style= "width:300px; height:200px;" /></interface> <interface id="image1" class="openapi" contenteditable="false"><img src="{{{richEditorDomain}}}tempFile/2021/025/0919/9pif.png" style= "width:300px; height:200px;" /></interface> <interface id="text3" class="openapi" contenteditable="false"><font color="blue">312312测试测试哈哈哈哈</font></interface> <interface id="text2" class="openapi" contenteditable="false"><font color="red">213123123这是啥阿三大苏打实打实的123</font></interface> <interface id="text1" class="openapi" contenteditable="false"><font >QERWWWWWW222323123</font></interface> <br></div></td><td><br></td></tr><tr><td><br></td><td><br></td></tr></tbody></table><div><br></div>""" } }
-
查询其他存在的索引visit_log,比较了一下区别
执行
GET /visit_log
,visit_log内容如下:{ "visit_log" : { "aliases" : { }, "mappings" : { "properties" : { . ...... } }, "settings" : { "index" : { "routing" : { "allocation" : { "include" : { "_tier_preference" : "data_content" } } }, "refresh_interval" : "1s", "number_of_shards" : "5", "provided_name" : "visit_log", "creation_date" : "1626223525799", "store" : { "type" : "fs" }, "number_of_replicas" : "1", "uuid" : "20dr00TpTtSsa4QEegFF8Q", "version" : { "created" : "7130399" } } } } }
执行
GET /edu_resourcereservation
,edu_resourcereservation内容如下,{ "edu_resourcereservation" : { "aliases" : { }, "mappings" : { "properties" : { . ...... } }, "settings" : { "index" : { "routing" : { "allocation" : { "include" : { "_tier_preference" : "data_content" } } }, "refresh_interval" : "-1", "number_of_shards" : "5", "provided_name" : "edu_resourcereservation", "creation_date" : "1626223525799", "store" : { "type" : "fs" }, "number_of_replicas" : "0", "uuid" : "TC-JnoQBSBSIDymyXYNIu9Q", "version" : { "created" : "7130399" } } } } }
-
区别就是一个叫
refresh_interval
的值为-1,改成1s。 这个属性有啥用? 刷新间隔,默认1s,近实时,文档从索引到可以被检索中间间隔就是这个值 https://blog.csdn.net/qq_28988969/article/details/103514918这个值为啥会是-1,因为从Gitee上clone下来的Java代码里面生成索引的时候给手动设死成-1啦。。。
PUT /edu_resourcereservation/_settings { "settings" : { "refresh_interval" : "1s" } }
解决办法:修改索引edu_resourcereservation属性settings的子属性refresh_interval
值为 1s
PUT /edu_resourcereservation/_settings
{
"settings" : {
"refresh_interval" : "1s"
}
}