Thursday, 8 June 2017

get and put request with nodejs to hbase

I was able to get integration between nodejs and HBASE rest api but have a problem with a couple things. Using the tutorial on :

http://blog.cloudera.com/blog/2013/03/how-to-use-the-apache-hbase-rest-interface-part-1/

I can make a connection and a GET but would like to retrieve all the columns from a row. Now if I specify the column family and qualifier, it works but not when I try to retrieve all columns.

var request = require('request');


request('http://192.xxx.xxx.xxx:8080/table1/http%3A%2F%2Fkeyurl.com%2F', 
function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});



 error: null
 statusCode: 400
 body: Bad request: Either 0 or more than 1 columns specified.

But if I specify the column family I get a return:

 var request = require('request');


request('http://192.xxx.xxx.xxx:8080/table1/http%3A%2F%2Fkeyurl.com%2Fdomain_data%3Aurl%2F', 
function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});



 ]# node sample.js
  error: null
  statusCode: 200
  body: http://keyurl.com/

Also if someone could help on how to structure a PUT command in nodejs:

 curl -vi -X PUT \
-H "Accept: text/json" \
-H "Content-Type: text/json" \
-d '{"Row":[{"key":"cm93NQo=", "Cell": [{"column":"Y2Y6ZQo=", 
"$":"dmFsdWU1Cg=="}]}]}'' \
"example.com:8000/users/fakerow"

So if I wanted to add multiple column values for a given row:

curl -vi -X PUT -H "Accept: text/json" -H "Content-Type: text/json" -d 
'{"Row":[{"url":"https://second.keyurl.com/", "Cell": 
[{"column":"domain_data", "$"url:"https://second.keyurl.com/"}, 
{"column":"domain_data", "$"insertDate:" 1496878958"}, 
{"column":"domain_data", "$"status:" Active"}]] 
http://192.xxx.xxx.xxx:8080/table1/https%3A%2F%2Fsecond.keyurl.com%2F



via vbNewbie

No comments:

Post a Comment