如何使用python在hbase里进行模糊查询?
0
我的rowkey为:1111_3333_abcd这样的。
请问如何使用python查询两个_间的数字为3333的记录?
请提供一下相关代码,多谢1
请问如何使用python查询两个_间的数字为3333的记录?
请提供一下相关代码,多谢1
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
1 个回复
Bob - 同程旅游大数据+BI 架构师 2015-10-27 回答
赞同来自: chenqiu1024
Python代码没有在生产环境运行,仅供参考。提供一种解决的思路吧
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
from hbase.ttypes import *
transport = TSocket.TSocket('localhost', 9090)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Hbase.Client(protocol)
filter = '{"type": "RowFilter", "op": "EQUAL", "comparator": {"type": "SubstringComparator", "value": "3333" }}'
transport.open()
scan = TScan()
scan.filterString=filter
scanner = client.scannerOpenWithScan('table_name', scan)