Filter using the HBase REST API

Does anyone know anything about the HBase REST API? Im currently writing a program that inserts and reads from HBase using curl commands. When trying to read, I use the curl get command, for example.

curl -X GET 'http://server:9090/test/Row-1/Action:ActionType/' -h 'Accept:application/json'

This returns the column Action: ActionType from row-1. If I want to make the equivalent of a WHERE clause using the GET command, I'm stuck. I'm not sure if this is even possible? If I want to find all records where Action: ActionType = 1, for example. Help is appreciated!

+4
source share
1 answer

You can do this using a filter (here a SingleColumnValueFilter) in a CURL request.

XML (myscanner.xml), . , EQUAL):

<Scanner batch="10">
    <filter>
        {
            "type": "SingleColumnValueFilter",
            "op": "EQUAL",
            "family": "<FAMILY_BASE64>",
            "qualifier": "<QUALIFIER_BASE64>",
            "latestVersion": true,
            "comparator": {
                "type": "BinaryComparator",
                "value": "<SEARCHED_VALUE_BASE64>"
            }
        }
    </filter>
</Scanner>

<FAMILY_BASE64>, <QUALIFIER_BASE64> <SEARCHED_VALUE_BASE64> ( base64, echo -en ${FAMILY} | base64.

CURL HBase REST API XML :

curl -vi -X PUT \
    -H "Content-Type:text/xml" \
    -d @myscanner.xml \
    "http://${HOST}:${REST_API_PORT}/${TABLE_NAME}/scanner/"

Scanner, :

[...]
Location: http://${HOST}:${REST_API_PORT}/${TABLE_NAME}/scanner/149123344543470bea57a

( ):

curl -vi -X GET \
    -H "Accept: text/xml" \
    "http://${HOST}:${REST_API_PORT}/${TABLE_NAME}/scanner/149123344543470bea57a"

"application/json" XML. , base64.

:

HEST HBase (SingleColumnValueFilter)

, : https://gist.github.com/stelcheck/3979381

Cloudera API- HBase REST: https://www.cloudera.com/documentation/enterprise/5-9-x/topics/admin_hbase_rest_api.html

+5

Source: https://habr.com/ru/post/1673618/


All Articles