Text vs Keyword Field Types in Elasticsearch
📖 Scenario: You are building a simple search system for a small online bookstore. You want to store book information in Elasticsearch. Some fields need to be searchable by full text, while others need exact matching.
🎯 Goal: Create an Elasticsearch index mapping that uses text and keyword field types correctly. Then add a document and query it to see the difference.
📋 What You'll Learn
Create an index mapping with a
title field of type textCreate an index mapping with an
isbn field of type keywordIndex a document with a sample book title and ISBN
Query the document by full text search on
titleQuery the document by exact match on
isbn💡 Why This Matters
🌍 Real World
Online stores and libraries use Elasticsearch to let users search books by title (full text) and filter by ISBN or categories (exact match).
💼 Career
Understanding <code>text</code> vs <code>keyword</code> fields is essential for building efficient search applications and indexing data correctly in Elasticsearch.
Progress0 / 4 steps