18 Ekim 2021 Pazartesi

Elasticsearch Index

Giriş
Açıklaması şöyle. Namespace gibi düşünülebilir.
You can think of an index in Elasticsearch as a database in the world of relational databases. To add data to Elasticsearch, we need to create an index. In reality, an index is just a logical namespace, data actually divided and stored into many shards. All data-related operations like CRUD perform on shards instead of index, index acts as a representative for hiding complexity.
Örnek
Şöyle yaparız. Burada ismi employee olan iki tane shard'dan oluşan ve her bir shard'ın iki tane replicası olan bir index yaratıyoruz
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/employee?pretty -d '
{
"settings": {
   "index": {
         "number_of_shards": 1,
         "number_of_replicas": 1
         }
      },
   "mappings": {
       "properties": {
         "age": {
               "type": "long"
         },
         "experienceInYears": {
               "type": "long"      
         },
         "name": {
               "type": "text"
         }
     }
   }
 } 
}'

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "employee"
}

Hiç yorum yok:

Yorum Gönder