<commit_before>Dharma Dictionary
==============

Prerequisites:
* install [Git](http://git-scm.com/)
* install [node.js](http://nodejs.org/) with npm (Node Package Manager)

Scripts:
* `npm run dev-server` -- run development server on 5000 port
* `npm run prod-server` -- run production server on 3000 port
* `npm run build` -- build client side sources for the production
* `npm start` -- run both development and production servers concurrently

Development:
* install nodejs dependencies `npm install`  (`sudo npm install` for mac)
* install nodejs dependencies for api-server (see "Production" section)
* run the app within the local memory via webpack `npm run dev-server`
* run the app in the prod mode to make /api requests work `npm run prod-server`
* or run both servers concurrently `npm start`
* go to http://localhost:5000/
* build client side for the prod via webpack `npm run build`

Production:
* `cd ./prod`
* install nodejs dependencies `npm install`  (`sudo npm install` for mac)
* run the app `node server.js`
* go to http://localhost:3000/<commit_msg>Instructions how do snapshot and restore that in elasticsearch.<commit_after>Dharma Dictionary
==============

Prerequisites:
* install [Git](http://git-scm.com/)
* install [node.js](http://nodejs.org/) with npm (Node Package Manager)

Scripts:
* `npm run dev-server` -- run development server on 5000 port
* `npm run prod-server` -- run production server on 3000 port
* `npm run build` -- build client side sources for the production
* `npm start` -- run both development and production servers concurrently

Development:
* install nodejs dependencies `npm install`  (`sudo npm install` for mac)
* install nodejs dependencies for api-server (see "Production" section)
* run the app within the local memory via webpack `npm run dev-server`
* run the app in the prod mode to make /api requests work `npm run prod-server`
* or run both servers concurrently `npm start`
* go to http://localhost:5000/
* build client side for the prod via webpack `npm run build`

Production:
* `cd ./prod`
* install nodejs dependencies `npm install`  (`sudo npm install` for mac)
* run the app `node server.js`
* go to http://localhost:3000/



# Instructions for creating snapshot and restore:

### Creating a snapshot
---
1. Need write a string, that will contain the path to snapshot, ```path.repo: ["/github/.../backups"]``` in file '/etc/elasticsearch/elasticsearch.yml'. This file possible open with next command:
```
sudo nano /etc/elasticsearch/elasticsearch.yml
```
2. If the first step was made, then in next command we can write relative path 'my_backup':
```
curl -XPUT 'http://localhost:9200/_snapshot/my_backup' -H 'Content-Type: application/json' -d'
{
    "type": "fs",
    "settings": {
        "location": "my_backup",
        "compress": true
    }
}'
```
In the folder "/github/.../backups" will appear a new folder "my_backup".
3. With the next command, you can verify that the repository was created:
```
curl -XGET 'http://localhost:9200/_snapshot/my_backup'
```
4. A snapshot with the name "shanp1" in the repository "my_backup" can be created by executing the following command:
```
curl -XPUT 'http://localhost:9200/_snapshot/my_backup/shanp1' {
    "indices": "dharmadict",
    "ignore_unavailable": true,
    "include_global_state": false
}
```


### Restore
---
1. Before restoring we need block index "dharmadict" in database:
```
curl -XPOST 'localhost:9200/dharmadict/_close?pretty'
```
2. Now, a snapshot can be restored using the following command:
```
curl -XPOST 'localhost:9200/_snapshot/my_backup/shanp1/_restore?pretty' -H 'Content-Type: application/json' -d'
{
  "indices": "dharmadict",
  "ignore_unavailable": true
}
'
```
{'fraction_non_alphanumeric': 0.12705248990578735, 'fraction_numerical': 0.01641991924629879, 'mean_word_length': 4.263456090651558, 'pattern_counts': {'":': 9, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1935315', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1072, 'n_words': 440}