I have a Hbase table: employeedetails with column families:cols-personaldetails: firstname, lastname, professionaldetails: cols-company, empid and it has the following data in it.
1 column=personaldetails:firstname, timestamp=1490959927100, value=Steven
1 column=personaldetails:lastname, timestamp=1490959947478, value=Gerrard
1 column=professionaldetails:company, timestamp=1490959968846, value=ABC
1 column=professionaldetails:empid, timestamp=1490959978542, value=02429O
2 column=personaldetails:firstname, timestamp=1490960007427, value=Sidhartha
2 column=personaldetails:lastname, timestamp=1490960054615, value=Bobby
2 column=professionaldetails:company, timestamp=1490960074243, value=DEF
2 column=professionaldetails:empid, timestamp=1490960103882, value=02429N
3 column=personaldetails:company, timestamp=1490960175772, value=WES
3 column=personaldetails:empid, timestamp=1490960187863, value=987789
3 column=personaldetails:firstname, timestamp=1490960128896, value=Sunny
3 column=personaldetails:lastname, timestamp=1490960142031, value=Smith
Is there a way to write a command to retrieve the records whose first name starts with 'S'.
Use SingleColumnValueFilter
This filter takes a column family, a qualifier, a compare operator and a comparator as arguments.
- If the specified column is not found, all the columns of that row will be emitted.
- If the column is found and the comparison with the comparator returns
true
, all the columns of the row will be emitted.- If the column is found and the comparison with the comparator returns
false
, the row will not be emitted.
Syntax:
SingleColumnValueFilter (‘<family>’, ‘<qualifier>’, <compare operator>, ‘<comparator>’, <filterIfColumnMissing_boolean>, <latest_version_boolean>)
Try:
scan 'employeedetails' ,{ FILTER => "SingleColumnValueFilter('personaldetails','firstname',=, 'binaryprefix:S', true, false)" }
If the filterIfColumnMissing
flag is set to true
, the columns of the row will not be emitted if the specified column to check is not found in the row.
Let me know if this retrieves expected results.