The problem was solved.
The roadmap was the following:
-
Use hive, no beeline.
-
Just copy elasticsearch-hadoop-6.4.3.jar to all data nodes and masters on /{HDP_HOME}/hadoop/lib/ (hortonworks to me)
-
Create index and type on elasticsearch
curl -X POST 'localhost:9200/bookindex/books' -H 'Content-Type: application/json' -d'
{
"bookId" : "A00-3",
"author" : "Sankaran",
"publisher" : "Mcgrahill",
"name" : "how to get a job"
}
' -
On hive always to do:
hive> add jar /usr/hdp/2.6.4.0-91/hadoop/lib/commons-httpclient-3.0.1.jar;
hive> add jar /usr/hdp/2.6.4.0-91/hadoop/lib/elasticsearch-hadoop-6.4.3.jar;
hive> CREATE EXTERNAL TABLE books ( bookId STRING, author STRING, publisher STRING, name STRING) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.nodes.wan.only'= 'TRUE', 'es.nodes.discovery' = 'false', 'es.nodes' = 'localhost', 'es.port' = '9200', 'es.resource' = 'bookindex/books');
hive> insert into books(bookid,author,publisher,name) values ('2','Pablo Neruda', 'Estrada','Poemas de Pablo Neruda');
hive> select count(*) from books;
hive>select * from books;
OK -
Check bookindex on elasticsearch!!
Enjoy!
Sergio.