[
  {
    "path": "README.md",
    "content": "# Beginner's Crash Course to Elastic Stack Series\n## Part 1: Intro to Elasticsearch & Kibana\n\nWelcome to the Beginner's Crash Course to Elastic Stack!\n\nThis repo contains all resources shared during workshop Part 1: Intro to Elasticsearch and Kibana.\n\nBy the end of this workshop, you will be able to:\n\n- understand a use case of Elasticsearch and Kibana\n- understand the basic architecture of Elasticsearch\n- perform CRUD(Create, Read, Update, and Delete) operations with Elasticsearch and Kibana\n\n## Resources\n\n[Beginner's Crash Course to Elastic Stack Table of Contents](https://github.com/LisaHJung/Beginners-Crash-Course-to-the-Elastic-Stack-Series) \n\nThis workshop is a part of the Beginner's Crash Course to Elastic Stack series. Check out this table contents to access all the workshops in the series thus far. This table will continue to get updated as more workshops in the series are released! \n\n[Free Elastic Cloud Trial](https://www.elastic.co/cloud/cloud-trial-overview/30-days?ultron=community-beginners-crash-course-May2022+&hulk=30d)\n\n[Instructions](https://dev.to/lisahjung/beginner-s-guide-to-setting-up-elasticsearch-and-kibana-with-elastic-cloud-1joh) on how to access Elasticsearch and Kibana on Elastic Cloud\n\n[Instructions](https://dev.to/elastic/downloading-elasticsearch-and-kibana-macos-linux-and-windows-1mmo) for downloading Elasticsearch and Kibana\n\n[Alternative installation using Docker](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/docker-compose.yml)\n\nOne of our AMAZING community member @h3ct0rjs has shared how you can run Elasticsearch and Kibana using Docker! Refer to this [link](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/docker-compose-directions.md) for his awesome step by step directions. Thank you so much @h3ct0rjs!!\n\n[Presentation](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/Intro%20to%20Elasticsearch%20and%20Kibana.pdf)\n\n[Video recording](https://www.youtube.com/watch?v=gS_nHTWZEJ8&t=8s) of the workshop\n\n[Mini Beginner's Crash Course to Elasticsearch & Kibana playlist](https://ela.st/mini-beginners-crash-course)\n\nDo you prefer learning by watching shorter videos? Check out this playlist to watch short clips of beginner's crash course full length workshops. Part 1 workshop is broken down into episodes 1-6. Season 2 clips will be uploaded here in the future! \n\n[Blog](https://dev.to/lisahjung/beginner-s-guide-to-elasticsearch-4j2k) Beginner's guide to Elasticsearch\n\n[Blog](https://dev.to/lisahjung/beginner-s-guide-to-performing-crud-operations-with-elasticsearch-kibana-1h0n) Beginner's guide to performing CRUD operations with Elasticsearch and Kibana\n\n[Elastic America Virtual Chapter](https://community.elastic.co/amer-virtual/) Want to attend live workshops? Join the Elastic America Virtual Chapter to get the deets!\n\n[What's next?](https://github.com/LisaHJung/Part-2-Understanding-the-relevance-of-your-search-with-Elasticsearch-and-Kibana-) Eager to continue your learning after mastering the concept from this workshop? Move on to Part 2: Understanding the relevance of your search with Elasticsearch and Kibana [here](https://github.com/LisaHJung/Part-2-Understanding-the-relevance-of-your-search-with-Elasticsearch-and-Kibana-)!\n\n## Getting information about cluster and nodes\nSyntax: \n```\nGET _API/parameter\n```\n### Get info about cluster health\n```\nGET _cluster/health\n```\nExpected response from Elasticsearch:\n\n![image](https://user-images.githubusercontent.com/60980933/101955613-64bd9000-3bbb-11eb-89da-564dd8680155.png)\n\n### Get info about nodes in a cluster\n```\nGET _nodes/stats\n```\nExpected response from Elasticsearch:\n\n![image](https://user-images.githubusercontent.com/60980933/101932662-5742de80-3b98-11eb-941c-7b654b16858c.png)\n\n## Performing CRUD operations\n\n## C - Create\n### Create an index\nSyntax:\n```\nPUT Name-of-the-Index\n```\nExample:\n```\nPUT favorite_candy\n```\n\nExpected response from Elasticsearch:\n\n![image](https://user-images.githubusercontent.com/60980933/101956137-5459e500-3bbc-11eb-823d-9a6871924afd.png)\n\n#### Index a document\nWhen indexing a document, both HTTP verbs `POST` or `PUT` can be used. \n\n1) Use POST when you want Elasticsearch to autogenerate an id for your document. \n\nSyntax:\n```\nPOST Name-of-the-Index/_doc\n{\n  \"field\": \"value\"\n}\n````\nExample:\n```\nPOST favorite_candy/_doc\n{\n  \"first_name\": \"Lisa\",\n  \"candy\": \"Sour Skittles\"\n}\n```\nExpected response from Elasticsearch:\n![image](https://user-images.githubusercontent.com/60980933/101933971-2d8ab700-3b9a-11eb-99a4-7d34b9819050.png)\n\n2) Use PUT when you want to assign a specific id to your document(i.e. if your document has a natural identifier - purchase order number, patient id, & etc).\nFor more detailed explanation, check out this [documentation](https://www.elastic.co/guide/en/elasticsearch/guide/current/index-doc.html) from Elastic! \n\nSyntax:\n```\nPUT Name-of-the-Index/_doc/id-you-want-to-assign-to-this-document\n{\n  \"field\": \"value\"\n}\n```\nExample:\n```\nPUT favorite_candy/_doc/1\n{\n  \"first_name\": \"John\",\n  \"candy\": \"Starburst\"\n}\n```\n### _create Endpoint\nWhen you index a document using an id that already exists, the existing document is overwritten by the new document. \nIf you do not want a existing document to be overwritten, you can use the _create endpoint! \n\nWith the _create Endpoint, no indexing will occur and you will get a 409 error message. \n\nSyntax:\n```\nPUT Name-of-the-Index/_create/id-you-want-to-assign-to-this-document\n{\n  \"field\": \"value\"\n}\n```\nExample:\n```\nPUT favorite_candy/_create/1\n{\n  \"first_name\": \"Finn\",\n  \"candy\": \"Jolly Ranchers\"\n}\n```\n\nExpected response from Elasticsearch:\n\n![image](https://user-images.githubusercontent.com/60980933/101937947-cf60d280-3b9f-11eb-8341-316ec4a69b35.png)\n\n## R - READ\n### Read a document \nSyntax:\n```\nGET Name-of-the-Index/_doc/id-of-the-document-you-want-to-retrieve\n```\nExample:\n```\nGET favorite_candy/_doc/1\n```\nExpected response from Elasticsearch:\n\n![image](https://user-images.githubusercontent.com/60980933/101935925-0d102c00-3b9d-11eb-9620-1b642364ef6a.png)\n\n## U - UPDATE\n### Update a document\n\nIf you want to update fields in a document, use the following syntax:\n```\nPOST Name-of-the-Index/_update/id-of-the-document-you-want-to-update\n{\n  \"doc\": {\n    \"field1\": \"value\",\n    \"field2\": \"value\",\n  }\n} \n```\nExample:\n```\nPOST favorite_candy/_update/1\n{\n  \"doc\": {\n    \"candy\": \"M&M's\"\n  }\n}\n```\nExpected response from Elasticsearch:\n\n![image](https://user-images.githubusercontent.com/60980933/101938690-05528680-3ba1-11eb-8eec-8e2dce678405.png)\n\n## D- DELETE\n### Delete a document\n\nSyntax:\n```\nDELETE Name-of-the-Index/_doc/id-of-the-document-you-want-to-delete\n```\nExample:\n```\nDELETE favorite_candy/_doc/1\n```\nExpected response from Elasticsearch:\n![image](https://user-images.githubusercontent.com/60980933/101939174-dab4fd80-3ba1-11eb-93fe-de682853bae4.png)\n\n## Take Home Assignment\n1. Create an index called `destinations`.\n2. Pick five dream travel destinations. For each destination, index a document containing the name and the country. \n3. Read(GET) each document to check the content of the document.\n4. Update a field of a document.\n5. Read(GET) the updated document to ensure that the field has been updated.\n6. Delete a document of one place.\n7. Copy and paste the following request to return all documents from the `destinations` index. \nThis is a great way to check whether all the CRUD operations you have performed thus far have worked!\n```\nGET destinations/_search\n{\n  \"query\": {\n    \"match_all\": {}\n  }\n}\n```\n"
  },
  {
    "path": "docker-compose-directions.md",
    "content": "Related Resource\n- [docker-compose.yml](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/docker-compose.yml)\n\nFor this Beginner's Crash Course, you can also use Docker to run Elasticsearch and Kibana this is not showed in the youtube video but it is optional and another popular way to install the software. You're going to find a docker-compose file that is going to deploy and install both Docker images using the following version.\n\n- elasticsearch:7.11.1\n- kibana:7.11.1\n\nIn order to be able to run this, you will need to have installed:\n\n- [Docker](https://docs.docker.com/desktop/linux/) or  [Docker Desktop](https://docs.docker.com/desktop/).\n- [Docker Compose](https://docs.docker.com/compose/).\n\nInstall Elasticsearch and Kibana by using the following command:\n\n```sh\ndocker-compose up -d\n```\n\nThe previous command is going to spin up two docker containers that will be in the same Docker network and in detached mode. With this, you will be able to open the following urls :\n\n* http://localhost:5601/ - Kibana Web UI interface\n* http://localhost:9200/ - Elastic Search API\n\nIf you want to check the logs :\n```sh\ndocker-compose logs elasticsearch\n```\nfor Kibana :\n```sh\ndocker-compose logs kibana\n```\nIf you want to stop Elasticsearch and Kibana, you will need to run the following command :\n```sh\ndocker-compose stop\n```\nIf you want to stop and destroy the docker services :\n\n```sh\ndocker-compose down\n```\n"
  },
  {
    "path": "docker-compose.yml",
    "content": "services:\n  elasticsearch:\n    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1\n    container_name: elasticsearch\n    #build: .\n    ports:\n      - '9200:9200'\n      - '9300:9300'\n    environment:\n      discovery.type: single-node\n      ES_JAVA_OPTS: -Xmx512m -Xms512m\n      node.name: es01\n      cluster.name: elasticsearch\n    volumes:\n      - ./elastic/data:/usr/share/elasticsearch/data\n    networks:\n      - elasticnet\n\n  kibana:\n    image: docker.elastic.co/kibana/kibana:7.11.1\n    container_name: kibana\n    ports:\n      - '5601:5601'\n      - '9600:9600'\n    environment:\n      SERVERNAME: kibana\n      ELASTICSEARCH_HOSTS: http://elasticsearch:9200\n      ES_JAVA_OPTS: -Xmx512m -Xms512m\n    networks:\n      - elasticnet\n    depends_on:\n      - elasticsearch\nvolumes:\n  logvolume01: {}\n\nnetworks:\n  elasticnet: {}\n  \n  \n"
  }
]