Define field types in mappings: text for search, keyword for exact match, date, float, geo_point.
Elasticsearch Mapping
# Define field types (like a DB schema)
PUT /posts
{
"mappings": {
"properties": {
"title": { "type": "text", "analyzer": "english" },
"body": { "type": "text" },
"author": { "type": "keyword" },
"tags": { "type": "keyword" },
"price": { "type": "float" },
"is_active": { "type": "boolean" },
"created_at": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||epoch_millis" },
"location": { "type": "geo_point" }
}
}
}
# View mapping
GET /posts/_mapping
# Types: text, keyword, integer, float, boolean, date, object, nested, geo_point