ES index API – part 1

RMAG news

Indices APIs

Index management:

Create Index
Delete Index
Get Index
Indices Exists
Open / Close Index API
Shrink Index
Split Index
Rollover Index

### Mapping management:

Put Mapping
Get Mapping
Get Field Mapping
Types Exists

Alias management:

Index Aliases

Index settings:

Update Indices Settings
Get Settings
Analyze
Index Templates

Monitoring:

Indices Stats
Indices Segments
Indices Recovery
Indices Shard Stores

Status management:

Clear Cache
Refresh
Flush
Force Merge

Create Index

index creation without any mapings

curl -X PUT “localhost:9200/twitter?pretty”

NOTE:

Index name limitations

There are several limitations to what you can name your index. The complete list of limitations are:

Lowercase only
Cannot include , /, *, ?, “, <, >, |, ` ` (space character), ,, #
Indices prior to 7.0 could contain a colon (:), but that’s been deprecated and won’t be supported in 7.0+
Cannot start with -, _, +
Cannot be . or ..
Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster)

Index Settings

To update index use this, in this payload we are detting mouner of shards and no of replicas

curl -X PUT “localhost:9200/twitter?pretty” -H ‘Content-Type: application/json’ -d’
{
“settings” : {
“index” : {
“number_of_shards” : 3,
“number_of_replicas” : 2
}
}
}

OR

curl -X PUT “localhost:9200/twitter?pretty” -H ‘Content-Type: application/json’ -d’
{
“settings” : {
“number_of_shards” : 3,
“number_of_replicas” : 2
}
}

Mappings

setting mappings to an index

curl -X PUT “localhost:9200/test?pretty” -H ‘Content-Type: application/json’ -d’
{
“settings” : {
“number_of_shards” : 1
},
“mappings” : {
“_doc” : {
“properties” : {
“field1” : { “type” : “text” }
}
}
}
}

setting Aliases

curl -XPUT localhost:9200/index1/_alias/index2

curl -X PUT “localhost:9200/test?pretty” -H ‘Content-Type: application/json’ -d’
{
“aliases” : {
“alias_1” : {},
“alias_2” : {
“filter” : {
“term” : {“user” : “kimchy” }
},
“routing” : “kimchy”
}
}
}
Please follow and like us:
Pin Share