50 lines
1.4 KiB
Bash
50 lines
1.4 KiB
Bash
#!/bin/bash
|
|
echo "Elasticsearch is now available. Proceeding with initialization..."
|
|
|
|
echo "Creating Elasticsearch indexes, roles, and users..."
|
|
|
|
# Command to create the "plans" index
|
|
curl -XPUT "http://localhost:9200/plans" -u elastic:elastic -H 'Content-Type: application/json' -d '{
|
|
"settings": {
|
|
"number_of_shards": 1,
|
|
"number_of_replicas": 1
|
|
},
|
|
"mappings": {
|
|
"properties": {
|
|
"title": { "type": "text" },
|
|
"description": { "type": "text" },
|
|
"price": { "type": "float" },
|
|
"date_added": { "type": "date" }
|
|
}
|
|
}
|
|
}'
|
|
|
|
# Command to create the "descriptions" index
|
|
curl -XPUT "http://localhost:9200/descriptions" -u elastic:elastic -H 'Content-Type: application/json' -d '{
|
|
"settings": {
|
|
"number_of_shards": 1,
|
|
"number_of_replicas": 1
|
|
},
|
|
"mappings": {
|
|
"properties": {
|
|
"product_id": { "type": "keyword" },
|
|
"description_text": { "type": "text" },
|
|
"language": { "type": "keyword" }
|
|
}
|
|
}
|
|
}'
|
|
|
|
curl -XPOST "localhost:9200/_security/role/opendmp-api-test" -u elastic:elastic -H 'Content-Type: application/json' -d '{
|
|
"indices": [
|
|
{
|
|
"names": [ "opendmp-*-test" ],
|
|
"privileges": [ "all" ]
|
|
}
|
|
]
|
|
}'
|
|
|
|
curl -XPOST "localhost:9200/_security/user/opendmp-api-test?pretty" -u elastic:elastic -H 'Content-Type: application/json' -d'
|
|
{
|
|
"password" : "your_password_here",
|
|
"roles" : [ "opendmp-api-test" ]
|
|
}' |