es的refresh操作


  理想情況下,數據一添加到索引中,就可以搜索到,但是一般不是這樣的。

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"
  }
}

  測試:

  發現同樣沒有效果


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM