-
aur/elasticsearch -
aur/kibana-bin -
installation
# first time
elasticsearch-keystore create
# the above command will create `/etc/elasticsearch/elasticsearch.keystore` file
# service
systemctl status elasticsearch
systemctl enable elasticsearch
systemctl start elasticsearch
# I don't know where to find the default password for `elastic` user
# just run below command to reset the password for `elastic` user
elasticsearch-reset-password -u elastic
# this will prompt for new password-
documentation:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html -
shards are for indices
- split api - increase shard count
- shrink api - decrease shard count
-
replication
- while creating index we can choose replica count
- a
replicais a copy of ashard
- view info
- cluster:
GET {{local}}/_cluster/health - node:
GET {{local}}/_cat/nodes?v=true - index:
GET {{local}}/_cat/indices?v=true
- cluster:
- get all documents
GET {{local}}/students/_search Content-Type: application/json { "query": { "match_all": {} } }
PUT {{local}}/students
Content-Type: application/json
{
"settings": {
"number_of_shards": "3",
"number_of_replicas": "3"
}
}POST {{local}}/students/_doc
Content-Type: application/json
{
"fullname": "Foo Bar",
"dob": "2000-01-01",
"gender": "male",
"address": "aaaaaaaa bbbbbbb",
"contact": "297234923498"
}POST {{local}}/students/_update/28
Content-Type: application/json
{
"script": {
"source": "ctx._source.address=(params.newAddress)",
"lang": "painless",
"params": {
"newAddress": "ssssssssss sssssssssss"
}
}
}POST {{local}}/students/_update/28
Content-Type: application/json
{
"doc": {
"address": "ssssssssss ttttttttttttttt"
}
}PUT /students
Content-Type: application/json
{
"mapping": {
"properties": {
"fullname": { "type": "text" },
"dob": { "type": "date", "format": "strict_date_optional_time||epoch_millis" },
"gender": { "type": "text" },
"address": { "type": "text" },
"email": { "type": "keyword" }
}
}
}# get mapping of an index
GET /students/_mapping
# get mapping of one field
GET /students/_mapping/field/addressadding new key to exiting mapping
PUT /students/_mapping
Content-Type: application/json
{
"properties": {
"class": { "type": "integer" },
"report": {
"type": "nested"
"properties": {
"class": { "type": "integer", "coerce": false },
"percentage": { "type": "float" }
}
}
}
}
## mapping options
- `"norms": false` - normaliztion, ranking; can be disabled if ranking not important for a field
- `"doc_values": false` - enabled by default, it should be enabled for aggregate operations. disabling increases indexing speed.
- `"coerce": false` - enable/disable automatic type coercion (enabled by default)
- `"index": false` - exclude a field from searching
- `"null_value": "NULL" - this is the default value should be used when document created with null value for this field. ES by default ignores null values & does not index it.