문서를 활용한 CRUD 작업
엘라스틱서치의 REST API를 사용하여 문서의 생성, 조회, 수정, 삭제 작업을 익히고 부분 수정도 다룹니다.
문서를 활용한 CRUD 작업은(는) CoddyKit의 무료 Elasticsearch & Full Text Search Systems 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Elasticsearch & Full Text Search Systems 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Elasticsearch & Full Text Search Systems 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What are CRUD Operations?
In the world of data, CRUD is a fundamental concept. It stands for Create, Read, Update, and Delete.
These are the four basic operations you perform on data in any system, including Elasticsearch. Mastering them is key to managing your search documents effectively.
Indexing New Documents
Adding a new document to Elasticsearch is called indexing. You can index documents:
- By letting Elasticsearch generate a unique ID (using
POST). - By providing your own custom ID (using
PUT).
The document content is sent as a JSON body.
Example: Indexing a Book
Let's index a book document. We'll use PUT and specify books/_doc/101 to give it a custom ID of 101.
PUT /books/_doc/101
{
"title": "The Hitchhiker's Guide to the Galaxy",
"author": "Douglas Adams",
"year": 1979
}Retrieving Documents
To fetch a document, you use the Get API. You just need to know its unique ID (_id) and the index it's in.
Elasticsearch will return the document's source (_source) along with metadata like its _index, _id, and _version.
Example: Getting Our Book
Now, let's retrieve the book we just indexed using its ID.
GET /books/_doc/101Full Document Replacement
One way to update a document is to completely replace it. You use the PUT method with the same document ID.
Be careful! Any fields missing from your new PUT request will be deleted from the original document.
Example: Adding a Genre
Let's add a genre field to our book. Notice how we provide the full document again, including existing fields.
PUT /books/_doc/101
{
"title": "The Hitchhiker's Guide to the Galaxy",
"author": "Douglas Adams",
"year": 1979,
"genre": "Science Fiction"
}Efficient Partial Updates
For small changes, fully replacing a document is inefficient. Elasticsearch provides the _update API for partial updates.
This allows you to send only the fields you want to change, making the operation faster and using less bandwidth. You use the POST method.
Example: Changing a Field
Let's update just the year field of our book using the _update API and the "doc" parameter. This merges the changes.
POST /books/_update/101
{
"doc": {
"year": 1980
}
}Removing Documents
To permanently remove a document from your index, you use the Delete API. Simply specify the index and the document's ID.
Once deleted, the document is gone and cannot be retrieved.
DELETE /books/_doc/101Quick Check
You have a document with fields name, age, and city. You want to change only the city field to a new value. Which is the most efficient and recommended way to do this in Elasticsearch?
Recap: CRUD in Elasticsearch
Great job! You've learned the essential CRUD operations for managing documents in Elasticsearch:
- Create (Index): Add new documents with
PUT(custom ID) orPOST(auto ID). - Read (Get): Retrieve documents by ID using
GET. - Update: Replace documents entirely with
PUTor perform efficient partial updates withPOST /_update. - Delete: Remove documents by ID using
DELETE.
These operations form the backbone of interacting with your Elasticsearch data.
자주 묻는 질문
“문서를 활용한 CRUD 작업” 강의는 무료인가요?
네 — “문서를 활용한 CRUD 작업” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Elasticsearch & Full Text Search Systems 강의 전체를 잠금 해제할 수 있습니다. Elasticsearch & Full Text Search Systems 강의에는 총 4개의 강의가 포함되어 있습니다.
“문서를 활용한 CRUD 작업”에서 뭘 배우나요?
엘라스틱서치의 REST API를 사용하여 문서의 생성, 조회, 수정, 삭제 작업을 익히고 부분 수정도 다룹니다. 브라우저에서 직접 실행하는 실습 코드로 Elasticsearch & Full Text Search Systems을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Elasticsearch & Full Text Search Systems을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Elasticsearch & Full Text Search Systems은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“문서를 활용한 CRUD 작업” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Elasticsearch & Full Text Search Systems 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Elasticsearch & Full Text Search Systems 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 엘라스틱서치에 문서 인덱싱
- 문서를 활용한 CRUD 작업
- 기본 매핑 및 데이터 유형
- 대량 인덱싱 및 대량 API