How to fetch data using sql query with elastic search through Sql4es jdbc_driver?


(Sachin Arora) #1

We are trying to get data from the elastic search using SQL queries but if I query for 'select * from table' it only returns fields name without field_data. here I'm using sql4es with its jdbc_driver for connection.
cassandra

public List findAll() {
try
{
Class.forName("nl.anchormen.sql4es.jdbc.ESDriver");
connection = DriverManager.getConnection("jdbc:sql4es://localhost:9300/projectmanagement?cluster.name=TestCluster");
java.sql.Statement statement = connection.createStatement();
java.sql.ResultSet rs = statement.executeQuery("SELECT * FROM user");
System.out.println(rs);
ResultSetMetaData rsmd = rs.getMetaData();
int nrCols = rsmd.getColumnCount();
while(rs.next()){
for(int i=1; i<=nrCols; i++){
System.out.println(rs.getObject(i));
}
}
rs.close();
connection.close();
}catch (Exception e)
{
System.out.println(e.getClass());
e.printStackTrace();
}
return mapper.map(session.execute(findAllStmt.bind())).all();
}

here is the list of fields_name


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.