Question

I want to search record base on value and my application in Java

I am store record using below code

HTable table = new HTable(conf, tableName);
Put put = new Put(Bytes.toBytes(rowKey));
put.add(Bytes.toBytes(family), Bytes.toBytes(qualifier),
        Bytes.toBytes(value));
table.put(put);

I pass values

    Put put = new Put(Bytes.toBytes("rowkey"));
    put.add(Bytes.toBytes("family1"), Bytes.toBytes("qualifier1"),
            Bytes.toBytes("this is test record"));

this is my get implementation

Get get = new Get(Bytes.toBytes("rowkey"));
            String[] family = { "row1" };
get.addColumn(Bytes.toBytes("family1"),Bytes.toBytes("qualifier1"));
Result rs = table.get(get);

now I want to search this record by "this is test record" value.

help me to found this record.

Was it helpful?

Solution

using filter you can do search on any of the element and you can pass different combination for SubstringComparator BinaryComparator

FilterList flist = new FilterList();

flist.addFilter(new RowFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("Predicatevalue"))));
flist.addFilter(new QualifierFilter(CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes("Subject value"))));
flist.addFilter(new ValueFilter(CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes("Objectvalue"))));

This work for me.

OTHER TIPS

Look at the get() method on HTable and the Get class, which are analogous to the put() method on HTable and the Put class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top