index.blocks.read_only | 1 true/false | 設置為true將使索引和索引元數(shù)據為只讀,設置為false將允許寫入和元數(shù)據更改。 |
有時我們需要在轉換文檔之前對其進行索引。例如,我們要從文檔中刪除一個字段或重命名一個字段,然后對其進行索引。這由Ingest節(jié)點處理。
群集中的每個節(jié)點都具有提取功能,但也可以對其進行自定義以僅由特定節(jié)點進行處理。
攝取節(jié)點的工作涉及兩個步驟-
創(chuàng)建管道
建立文件
首先創(chuàng)建一個包含處理器的管道,然后執(zhí)行該管道,如下所示-
PUT _ingest/pipeline/int-converter { "description": "converts the content of the seq field to an integer", "processors" : [ { "convert" : { "field" : "seq", "type": "integer" } } ] }
在運行上面的代碼時,我們得到以下結果-
{ "acknowledged" : true }
接下來,我們使用管道轉換器創(chuàng)建一個文檔。
PUT /logs/_doc/1?pipeline=int-converter { "seq":"21", "name":"nhooo", "Addrs":"Hyderabad" }
運行上面的代碼后,我們得到如下所示的響應:
{ "_index" : "logs", "_type" : "_doc", "_id" : "1", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1 }
接下來,我們使用GET命令搜索上面創(chuàng)建的文檔,如下所示-
GET /logs/_doc/1
在運行上面的代碼時,我們得到以下結果-
{ "_index" : "logs", "_type" : "_doc", "_id" : "1", "_version" : 1, "_seq_no" : 0, "_primary_term" : 1, "found" : true, "_source" : { "Addrs" : "Hyderabad", "name" : "nhooo", "seq" : 21 } }
您可以在上方看到21變?yōu)檎麛?shù)。
現(xiàn)在,我們無需使用管道即可創(chuàng)建文檔。
PUT /logs/_doc/2 { "seq":"11", "name":"Tutorix", "Addrs":"Secunderabad" } GET /logs/_doc/2
在運行上面的代碼時,我們得到以下結果-
{ "_index" : "logs", "_type" : "_doc", "_id" : "2", "_version" : 1, "_seq_no" : 1, "_primary_term" : 1, "found" : true, "_source" : { "seq" : "11", "name" : "Tutorix", "Addrs" : "Secunderabad" } }
您可以在上面看到11是一個不使用管道的字符串。