{"id":18733373,"url":"https://github.com/icij/datashare-playground","last_synced_at":"2025-04-12T18:31:36.092Z","repository":{"id":173093468,"uuid":"647780496","full_name":"ICIJ/datashare-playground","owner":"ICIJ","description":"A zero-dependencies series of bash script to interact with Datashare's index and queue.","archived":false,"fork":false,"pushed_at":"2025-03-25T10:30:16.000Z","size":78,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-26T12:51:13.268Z","etag":null,"topics":["bash","curl","elasticsearch","redis"],"latest_commit_sha":null,"homepage":"https://datashare.icij.org/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ICIJ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-31T14:01:16.000Z","updated_at":"2024-07-10T09:26:32.000Z","dependencies_parsed_at":"2023-09-29T11:03:57.315Z","dependency_job_id":null,"html_url":"https://github.com/ICIJ/datashare-playground","commit_stats":null,"previous_names":["icij/datashare-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICIJ%2Fdatashare-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICIJ%2Fdatashare-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICIJ%2Fdatashare-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICIJ%2Fdatashare-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ICIJ","download_url":"https://codeload.github.com/ICIJ/datashare-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248613483,"owners_count":21133522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","curl","elasticsearch","redis"],"created_at":"2024-11-07T15:09:30.045Z","updated_at":"2025-04-12T18:31:35.722Z","avatar_url":"https://github.com/ICIJ.png","language":"Shell","readme":"# Datashare Playground [![](https://img.shields.io/github/actions/workflow/status/icij/datashare-playground/main.yml)](https://github.com/ICIJ/datashare-playground/actions)\n\n![Datashare: Better analyze information, in all its forms](https://i.imgur.com/9SPU1x2.png)\n\n\u003cp align=\"center\"\u003e\nA zero-dependencies series of bash scripts to interact with Datashare's index and queue.\u003cbr /\u003e\n\u003ca href=\"#setup\"\u003eSetup\u003c/a\u003e | \u003ca href=\"#scripts\"\u003eScripts\u003c/a\u003e | \u003ca href=\"#test\"\u003eTest\u003c/a\u003e | \u003ca href=\"#cookbook\"\u003eCookbook\u003c/a\u003e\n\u003c/p\u003e\n\n## Setup\n\nTo run those scripts only needs to have access to the ElasticSearch URL which must be stored in an \nenvironement variable called `ELASTICSEARCH_URL`. Same logic applies to `REDIS_URL`. To avoid setting up \nthis variable everytime you use those script, you can store in a `.env` at the root of this directory:\n\n```bash\nELASTICSEARCH_URL=http://localhost:9200\nREDIS_URL=redis://redis\n```\n\n## Scripts\n\nHere are the main scripts available in this repository:\n\n```bash\n.\n├── elasticsearch\n│   │\n│   ├── document\n│   │   ├── count.sh # Count documents under a given path\n│   │   ├── delete.sh # Delete documents under a given path\n│   │   ├── move.sh # Move documents from a directory to another\n│   │   └── reindex.sh # Reindex documents from a given index and under a specific directory\n│   │\n│   ├── duplicate\n│   │   ├── count.sh # Count duplicates\n│   │   └── reindex.sh # Reindex duplicates from a given index\n│   │\n│   ├── index\n│   │   ├── clone.sh # Clone a given index into another\n│   │   ├── create.sh # Create an index using default Datashare settings\n│   │   ├── delete.sh # Delete an index\n│   │   ├── list.sh # Get all indices\n│   │   ├── number_of_replicas.sh # Get or change number of replicas for a given index\n│   │   ├── refresh_interval.sh # Get or change refresh interval for a given index\n│   │   ├── refresh.sh # Refresh a given index\n│   │   ├── reindex.sh # Reindex everything from a given index\n│   │   └── replace.sh # Replace an index by another one\n│   │\n│   ├── named_entity\n│   │   ├── count.sh # Count named entities\n│   │   └── reindex.sh # Reindex named entities from a given index\n│   │\n│   └── task\n│       ├── cancel.sh # Cancel a given task\n│       ├── get.sh # Get a given task status\n│       ├── list.sh # Get all tasks\n│       └── watch.sh # Watch a given task status\n│\n├── redis\n│   │\n│   ├── queue\n│   │   └── rpush.sh # Insert stdin rows to a given queue\n│   │\n│   └── report\n│       ├── hdel.sh # Remove stdin rows from a given report map\n│       └── hset.sh # Insert stdin rows to a given report map\n│\n└── lib\n    └── sync.sh # Sync this directory with another location with rsync\n```\n\n## Test \n\nDeveloppers can run tests using [bats](https://github.com/bats-core/bats-core):\n\n```bash\nexport ELASTICSEARCH_URL=http://localhost:9200 # Change this with the URL of ElasticSearch \nmake tests\n```\n\n## Cookbook\n\nThis cookbook list real-life examples of how to use those scripts.\n\n### Copy documents from a given index to another\n\nAn example showing how to copy documents from the `kimchi` index to the `miso` while taking care of updating the path.\n\n**1. Create a clone of the \"miso\" index to avoid messing up with data:**\n\n```bash\n./elasticsearch/index/clone.sh miso miso-tmp\n```\n\n**2. Reindex documents from `kimchi` under the folder `/disk/kimchi/tofu` onto `miso-tmp`:**\n\n```bash\n./elasticsearch/index/reindex.sh kimchi miso-tmp /disk/kimchi/tofu\n```\n\n**3. While the reindex is being done, watch progress using the task id from the last command:**\n\n```bash\n./elasticsearch/task/watch.sh 8UnTR-67T8y0idkyndf77Q:36041259\n```\n\n**4. The document moved to `miso-tmp` use the wrong path so we update it as well:**\n\n```bash\n./elasticsearch/document/move.sh miso-tmp /disk/kimchi/tofu /disk/miso/tofu\n```\n\n**5. Finally, after checking everything is fine, we substitue the `miso` index by `miso-tmp`:**\n\n```bash\n./elasticsearch/index/replace.sh miso-tmp miso\n```\n\n### Re-index an index\n\nThis opperation might be useful if mapping or settings of the index changed. \n\n\n**1. Create a `ricecake-tmp` empty index:**\n\n```bash\n./elasticsearch/index/create.sh ricecake-tmp\n```\n\n**1'. Alternatively, you can create a `ricecake-tmp` empty index with the mappings/settings of the desired version:**\n\n```bash\n./elasticsearch/index/create.sh ricecake-tmp 17.1.1\n```\n\n**2. Reindex all documents (under \"/\" path) from `ricecake` under to `ricecake-tmp`:**\n\n```bash\n./elasticsearch/documents/reindex.sh ricecake ricecake-tmp /\n```\n\n**3. Replace the old `ricecake` by the new one:**\n\n```bash\n./elasticsearch/index/replace.sh ricecake-tmp ricecake\n```\n\n### Queue files (for indexing)\n\nThis will get files from `find` and store them in the `extract:queue` list:\n\n```bash\nfind /home/foo/bar -type f | ./redis/queue/rpush.sh extract:queue\n```\n\nOr to filtered that list with a `filtered.txt` file:\n\n```bash\nfind ~+ -type f | grep -vFf filtered.txt | ./redis/queue/rpush.sh extract:queue\n```\n\nThis can also be done with a single file:\n\n```bash\necho \"/file/to/index.pdf\" | ./redis/queue/rpush.sh extract:report\n```\n\n### Add files to a report map\n\nReport map are used to store error and skip already indexed files.\n\n```bash\nfind /home/foo/bar -type f | ./redis/report/hset.sh extract:report\n```\n### Delete files from a report map\n\nThis can be usefull to force a reindex on certain files:\n\n```bash\ncat to-reindex.txt | ./redis/report/hdel.sh extract:report\n```\n\nThis can also be done with a single file:\n\n```bash\necho \"/file/to/reindex.pdf\" | ./redis/report/hdel.sh extract:report\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficij%2Fdatashare-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficij%2Fdatashare-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficij%2Fdatashare-playground/lists"}