Elasticsearch command note

pleng
1 min readSep 19, 2022
  1. command for look up mapping document
GET /books

2. command for count document

GET /books/_count

3. command for look up document

GET /books/_search

5. command for reindex from old to new

  • if put parameter wait_for_completion = false will separate work and can monitor task with command GET _tasks/{{task-id}}
POST _reindex?wait_for_completion=false
{
"source": {
"index": "books"
},
"dest": {
"index": "new-books"
}
}

6. command for mapping new field to existing index

  • example is add filed keyword in name and use analyzer is keyword
    and min character for begin to cut is 10 and max is 20
PUT /books/_mapping
{
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "text",
"analyzer": "keyword",
"index_prefixes": {
"min_chars": 10,
"max_chars": 20
}
}
}
}
}
}

7. update data for new index

  • conflicts is proceed is mean not index if another index is processing
POST books/_update_by_query?conflicts=proceed&wait_for_completion=false

--

--