- Делаем бэкап
pg_dump -U taskuser taskdb > backup.sql
- Устанавливаем elasticdump
npm install elasticdump -g
- Бэкап схем
elasticdump --input=http://127.0.0.1:9200/content --output=es_mapping.json --type=mapping
- Бэкап данных
elasticdump --input=http://127.0.0.1:9200/content --output=es_index.json --type=data
- Удаляем старые данные и настраиваем заново taskdb
psql -U postgres -d taskdb -c "DROP SCHEMA public CASCADE;"
psql -U postgres -d taskdb -c "CREATE SCHEMA public;"
psql -U postgres -d taskdb -c "GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO public;"
- Восстанавливаем из бэкапа
psql -U postgres -d taskdb -f backup.sql
- Останавливаем elastic, удаляем каталог с индексами (elasticpath/data/node/), запускаем elastic
- Устанавливаем elasticdump
npm install elasticdump -g
- Восстанваливаем схемы из файла бэкапа
elasticdump --input=es_mapping.json --output=http://127.0.0.1:9200/content --type=mapping
- Восстанваливаем данные из файла бэкапа
elasticdump --input=es_index.json --output=http://127.0.0.1:9200/content --type=data
- Поиск по значению поля
GET /index_name/_search
{
"query": {
"multi_match" : {
"query": "search_string",
"fields": [ "field_name" ]
}
}
}
- Обновление поля
POST /index/type/id/_update
{
"doc" : {
"field_name" : new_value
}
}
Пример:
POST /content/_doc/39653d8d-2191-469a-8d4a-bd4f19b71232/_update
{
"doc" : {
"type" : "SbisDocumentMdl"
}
}
- Удаление по полю
POST /index_name/_delete_by_query
{
"query": {
"multi_match" : {
"query": "search_string",
"fields": [ "field_name" ]
}
}
}
Пример:
POST /content/_delete_by_query
{
"query": {
"multi_match" : {
"query": "ShowDocsMdl",
"fields": [ "type" ]
}
}
}
- Поиск по пустому полю (data:{})
GET /index_name/_search
{
"query":{
"bool":{
"must_not":[
{
"exists":{
"field":"tags"
}
}
]
}
}
}
- Поиск с условием И/ИЛИ
GET /index_name/_search
{
"query" : {
"bool": { //bool indicates we are using boolean operator
"must" : [ //must is for **AND**
{
"match" : {
"description" : "some text"
}
},
{
"match" :{
"type" : "some Type"
}
}
]
}
}
}
{
"query" : {
"bool": { //bool indicates we are using boolean operator
"should" : [ //must is for **OR**
{
"match" : {
"description" : "some text"
}
},
{
"match" :{
"type" : "some Type"
}
}
]
}
}
}