理想情况下,数据一添加到索引中,就可以搜索到,但是一般不是这样的。
1.实验
PUT /start/_doc/1
{
"name":"湖66"
}
GET /start/_doc/1
效果:
# PUT /start/_doc/1
{
"_index" : "start",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
# GET /start/_doc/1
{
"_index" : "start",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"name" : "湖66"
}
}
2.再测
使用链式请求命令,打开终端进行执行
curl -X PUT localhost:9200/start/_doc/4 -H 'Content-Type:application/json' -d '{"name":"湖99"}'
curl -X GET localhost:9200/start/_doc/_search?pretty -H 'Content-Type:application/json'
但是执行完,还是可以查询到,时间太短了,有点难实现。
3.理论上做法
curl -X PUT localhost:9200/star/_doc/666?refresh -H 'Content-Type:application/json' -d '{ "displayName": "杨超越" }'
4.修改默认的更新时间
PUT /start/_settings
{
"index":{
"refresh_interval":"5s"
}
}
再测:
没有效果,后期看
5.关闭刷新
PUT /start/_settings
{
"index":{
"refresh_interval":"-1"
}
}
测试:
发现同样没有效果