Documents in Elasticsearch are self-contained units that hold all related data fields. They can be indexed and searched independently, making them the fundamental unit of data.
{
"_index": "products",
"_id": "1",
"result": "created"
}The 'result' field with value 'created' means the document was successfully added to the specified index with the given ID.
{
"query": {
"term": { "status": "active" }
}
}The 'term' query matches documents where the field exactly equals the given value, so only documents with 'status' exactly 'active' are returned.
{
"name": "Widget",
"price": 25.5,
"available": true
}In JSON, boolean values must be true or false, not yes or no. Using 'yes' causes a parsing error.
More complex documents with many nested fields require more processing during indexing and searching, which can reduce performance.
