I'm new to elasticsearch and as far as I've read, _id field is not accesible via sql endpoint at the moment.
I've read some posts about duplicating it as a regular field in order to reach via sql endpoint. But I cannot find a document about how to actually do it.
Easiest thing is to do that from the client which is sending data to Elasticsearch:
PUT /index/_doc/1
{
"id": "1",
"foo": "bar"
}
If this does not work for you, there are many other options, like using runtime fields or using an ingest pipeline to set this value automatically at index time... Something like:
I need to extract data from elasticsearch into a relational database. Since the data contains no logical unique keys (even not a composite one), I have to rely elastic _id field to ensure data consistency. But I cannot reach the field via elasticsearch JDBC driver.
As far as I understand, it's easy for the team to make _id field accesible via sql endpoint. But things get complicated when it comes to other sql functionality like aggregations, grouping etc. Therefore they chose not to include that functionality altogether.
Several requests have been made over the years but all have been dismissed. Some directly by denial, some indirectly via redirecting to other requests and have them closed due to inactivity.
I'll forward those to our elastic admin to see if we can do it.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.