Usually ElasticSearch documents are stored as:
{
"_index": "some_index",
"_type": "some_type",
"_id": "blah_blah",
"_score": null,
"_source": {
"field_a" : "value_a",
"field_b" : "value_b"
........
}
Is it possible to include _id in the _source itself while querying the data? e.g.
{
"_index": "some_index",
"_type": "some_type",
"_id": "blah_blah",
"_score": null,
"_source": {
"_id": "blah_blah", // Added in the _source object
"field_a" : "value_a",
"field_b" : "value_b"
........
}
Let's assume I do not have control over the data I am writing so cannot insert it in the source. Also, I can read the entire object and manually include it but wondering if there is a way to do so via ES query.
The _id (metadata _id, that is) is a string value. created). You have complete freedom to set it to any string value you wish. use it quite effectively in this way.
The ID is now generated with a time based element, but the byte re-ordering causes it not to be sortable by time. You could write a script field using Painless that would put it back in sortable order and then use that.
Instead of storing information as rows of columnar data, Elasticsearch stores complex data structures that have been serialized as JSON documents. When you have multiple Elasticsearch nodes in a cluster, stored documents are distributed across the cluster and can be accessed immediately from any node.
To get the ID of a document, simply use the _id field in the search query. For example, if you want to find the document with the ID "12345", you would use the following query: _id:12345. This would return the document with the ID "12345".
The _id field is neither indexed nor stored, meaning it dosen't really exist. The _type field is only indexed ,but not stored. _id and _type are both matedata of elasticsearch, they concatenated together as id#type(_uid).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With