{"id":23463557,"url":"https://github.com/arielfr/grunt-elastic-sc","last_synced_at":"2026-05-05T22:43:05.503Z","repository":{"id":72461099,"uuid":"41764480","full_name":"arielfr/grunt-elastic-sc","owner":"arielfr","description":"ElasticSearch Source Control","archived":false,"fork":false,"pushed_at":"2015-09-03T13:37:46.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T01:43:29.970Z","etag":null,"topics":["elasticsearch","grunt","node","nodejs","source-control","task"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/arielfr.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}},"created_at":"2015-09-01T21:30:35.000Z","updated_at":"2017-03-21T20:22:20.000Z","dependencies_parsed_at":"2023-02-28T00:56:16.164Z","dependency_job_id":null,"html_url":"https://github.com/arielfr/grunt-elastic-sc","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arielfr%2Fgrunt-elastic-sc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arielfr%2Fgrunt-elastic-sc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arielfr%2Fgrunt-elastic-sc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arielfr%2Fgrunt-elastic-sc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arielfr","download_url":"https://codeload.github.com/arielfr/grunt-elastic-sc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565079,"owners_count":21125415,"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":["elasticsearch","grunt","node","nodejs","source-control","task"],"created_at":"2024-12-24T09:12:49.811Z","updated_at":"2026-05-05T22:43:05.436Z","avatar_url":"https://github.com/arielfr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grunt ElasticSearch Source Control\n\nThis is a Grunt set of tasks for source control your ElasticSearch. I know it's not quite necessary to have a source control on your ES installation. But, when you work with pairs, it's not confortable when all of you need to update the your mappings or add custom data to your types.\n\nWhit this Tasks, you will be able to create a Master Changelog when you references your Changelogs. In this changelogs you can Create Mappings, Add Data and Delete Data having full control.\n\nIf you make a change and push your changes, then your partner can pull and update his ES with a simple grunt command.\n\n## Add to package.json\n\nYour need to add to your dependencies\n\n```\n\"dependencies\": {\n\t\"grunt-elastic-sc\": \"X.X.X\"\n}\n```\n\n## Usage - Tasks\n\nYou have two main tasks\n\n- sc-create\n- sc-process\n\nYou must create this directory structure on your project.\n\n```\n-\u003e es-source-control\n\t-\u003e changelogs\n\t-\u003e sc-master.json\n```\n\n## sc-master.json - Master Changelog File\n\nThis will be the master changelog file. This file is going to have the changelogs references to execute.\n\n```\n{\n\t\"changelogs\": [\n\t\t{\n\t\t\t\"id\": \"create-testing\",\n\t\t\t\"folder\": \"testing\",\n\t\t\t\"file\": \"mapping\",\n\t\t\t\"type\": \"mapping\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"add-data\",\n\t\t\t\"folder\": \"testing\",\n\t\t\t\"file\": \"data\",\n\t\t\t\"type\": \"data\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"deleting-data\",\n\t\t\t\"folder\": \"testing\",\n\t\t\t\"file\": \"delete\",\n\t\t\t\"type\": \"delete\"\n\t\t},\n\t\t{\n\t\t...\n\t\t}\n\t]\n}\n```\n\nThe **id** must be unique.\n\nAll the changelogs are going to be find on the folder \"changelogs\" on your \"es-source-control\" root directory.\n\n### sc-create - Create Index for Source Control\n\nThis task will create an index called \"sc\". With this index, a type called \"changelogs\" also be created. This type is going to contain the ids already executed. This will keep the control of the code already executed.\n\nThe next are the properties of \"changelogs\"\n\n```\n\"properties\": {\n    \"id_runned\": { \"type\": \"string\", \"index\": \"not_analyzed\" },\n    \"success\": { \"type\":\"boolean\" },\n    \"run_date\": { \"type\": \"date\" }\n}\n```\n\n### sc-process - Execute the changelogs\n\nThis task will execute all the changelog that aren't yet executed\n\nParameters:\n\n- from: This parameter should be populated with the id of the changelog from when we want to start executed the changes (not included).\n\nExample:\n```\ngrunt sc-process --from=add-data\n```\n\nFollow this example, this command will only execute \"deleting-data\".\n\n**This command should be used when you update your ES from a Snapshot, and you don't want to execute the previous changes again (Assuming your \"es\" Index is empty or outdated). If you are going to use this option all the time, add it to your Gruntfile configurations.**\n\n#### Add Data\n\nTo add data, the JSON file should be like this:\n\n```\n{\n\t\"changes\": [\n\t\t{\n\t\t\t\"index\": \"sc\",\n\t\t\t\"type\": \"test_mapping\",\n\t\t\t\"records\": [\n\t\t\t\t{\n\t\t\t\t\t\"id\": 1,\n\t\t\t\t\t\"text\": \"This is a text message 1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"id\": 2,\n\t\t\t\t\t\"text\": \"This is a text message 2\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t...\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n}\n```\n\n- Index \u0026 Type would be the ones you are wanting to add the data.\n- The records are going to be the \"body\" tag to send to ElasticSearch. This is an array, so you can send 1 or more.\n\n#### Add Type - Mapping\n\nTo add a type, the JSON file should be like this:\n\n```\n{\n\t\"changes\": [\n\t\t{\n\t\t\t\"index\": \"sc\",\n\t\t\t\"type\": \"test_mapping\",\n\t\t\t\"body\": {\n\t\t\t\t\"test_mapping\": {\n\t\t\t\t\t\"_all\": { \"enabled\": false },\n\t\t\t\t\t\"dynamic\": false,\n\t\t\t\t\t\"_id\": {\n\t\t\t\t\t\t\"path\": \"id\"\n\t\t\t\t    },\n\t\t\t\t    \"properties\": {\n\t\t\t\t    \t\"id\": { \"type\": \"integer\" },\n\t\t\t\t    \t\"text\": { \"type\": \"string\", \"index\": \"not_analyzed\" }\n\t\t\t\t    }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t]\n}\n```\n\n- The Index would be the index to add the type.\n- The type is going to be the type to add\n- The body should be the body to be sended to ElasticSearch\n\n#### Delete by Query\n\nTo make a delete by query, the JSON file should be like this:\n\n```\n{\n\t\"changes\": [\n\t\t{\n\t\t\t\"index\": \"sc\",\n\t\t\t\"type\": \"test_mapping\",\n\t\t\t\"records\": [\n\t\t\t\t{\n\t\t\t\t\t\"query\": {\n\t\t\t\t\t\t\"term\": {\n\t\t\t\t\t\t\t\"id\": 3\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n}\n```\n\n- The Index and Type would be the ones to perform the delete.\n- The records are going to contain the query tag to execute. In this case, we are going to delete all the elements that have the id = 3\n\n## Example\n\nOn the package folder, you will find a basic example already created\n\n## Collaboration\n\nThis is a base for creating a better Souce Control for ElasticSearch, all Forks and PR would be accepted. Thanks!\n\n## License\n```\nThe MIT License (MIT)\n\nCopyright (c) \u003c2015\u003e \u003cAriel Rey\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farielfr%2Fgrunt-elastic-sc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farielfr%2Fgrunt-elastic-sc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farielfr%2Fgrunt-elastic-sc/lists"}