Run on Docker
Use the following command to run Elasticsearch in a docker container-
docker run -d \
--name elasticsearch \
-e discovery.type=single-node \
-e bootstrap.memory_lock=true \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-e xpack.security.enabled=true \
-e xpack.security.authc.api_key.enabled=true \
--ulimit memlock=-1:-1 \
-p 9200:9200 -p 9300:9300 \
-v es_data:/usr/share/elasticsearch/data \
docker.elastic.co/elasticsearch/elasticsearch:8.10.1
BashHere is the meaning of all the params and flags passed to the command-
Run the following command to set(reset) the password-
docker exec -it elasticsearch bin/elasticsearch-reset-password -u elastic
BashYou will get some output like below-
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y
Password for the [elastic] user successfully reset.
New value: lQhYLyUsgRUFVfZYExG7
BashYou can see the password.
Check Elasticsearch Installation
Check using Postman
In the Authorization tab, use-
- Authentication Tab
- Auth Type: Basic Auth
- Enter the authentication values-
- User Name
- Password
- Request Method: GET
- URL: http://localhost:9200

Let’s add some products to the “products” index.
Add product-
- Request type: POST
- URL: http://localhost:9200/products/_doc/
- Body: raw > JSON
Use the request body-
{
"name": "Elasticsearch Guide",
"author": "John Doe",
"category": "Technology",
"published": "2025-02-01"
}
JSONHere is the response we get-
{
"_index": "products",
"_id": "deBYA5UB807SjwxPX5cK",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 1,
"_primary_term": 1
}
JSONHere is a screenshot from postman-

To search the products, use the following info-
- Request type: POST
- URL: http://localhost:9200/products/_search
- Use Body: raw > JSON
Use the following request body-
{
"query": {
"match_all": {}
}
}
JSONWe would get the following output-
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "products",
"_id": "dOBUA5UB807SjwxP8Zfq",
"_score": 1.0,
"_source": {
"name": "Elasticsearch Guide",
"author": "John Doe",
"category": "Technology",
"published": "2025-02-01"
}
},
{
"_index": "products",
"_id": "deBYA5UB807SjwxPX5cK",
"_score": 1.0,
"_source": {
"name": "BigBoxCode",
"author": "BigBox Auth",
"category": "Technology",
"published": "2025-02-01"
}
}
]
}
}
JSONHere is the request screenshot-
