Skip to content

Commit 56869c4

Browse files
committed
adapt fulltext query
1 parent 0caee1b commit 56869c4

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/ObTableQuery.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class ObTableQuery extends AbstractPayload {
6565

6666
private static final byte[] HTABLE_DUMMY_BYTES = new byte[] { 0x01, 0x00 };
6767
private boolean isHbaseQuery = false;
68+
private boolean isFTSQuery = true;
6869
private List<String> scanRangeColumns = new LinkedList<String>();
6970

7071
private List<ObTableAggregationSingle> aggregations = new LinkedList<>();
@@ -507,18 +508,21 @@ public void setObKVParams(ObKVParams obKVParams) {
507508
}
508509

509510
public void setSearchText(String searchText) {
510-
if (isHbaseQuery) {
511+
if (this.isHbaseQuery) {
511512
throw new FeatureNotSupportedException("Hbase query not support full text search currently");
512513
}
513-
if (obKVParams == null) {
514+
if (this.obKVParams == null) {
514515
obKVParams = new ObKVParams();
515516
}
516517
ObFTSParams ftsParams = (ObFTSParams)obKVParams.getObParams(ObKVParamsBase.paramType.FTS);
517518
ftsParams.setSearchText(searchText);
518-
obKVParams.setObParamsBase(ftsParams);
519+
this.obKVParams.setObParamsBase(ftsParams);
520+
this.isFTSQuery = true;
519521
}
520522

521523
public ObKVParams getObKVParams() {
522524
return obKVParams;
523525
}
526+
527+
public boolean isFTSQuery() { return isFTSQuery; }
524528
}

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientQueryImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ private AbstractQueryStreamResult commonExecute(InitQueryResultCallback<Abstract
158158
// fill a whole range if no range is added explicitly.
159159
if (tableQuery.getKeyRanges().isEmpty()) {
160160
tableQuery.addKeyRange(ObNewRange.getWholeRange());
161+
} else if (tableQuery.isFTSQuery()) {
162+
// Currently, fulltext query only support scan all partitions
163+
tableQuery.getKeyRanges().clear();
164+
tableQuery.addKeyRange(ObNewRange.getWholeRange());
161165
}
162166

163167
// init partitionObTables

src/test/java/com/alipay/oceanbase/rpc/ObTableFullTextIndexTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ObTableFullTextIndexTest {
2727
ObTableClient client;
2828
String tableName = "tbl1";
2929
String ttlTableName = "ttl_tbl1";
30-
String createTableSQL = "CREATE TABLE IF NOT EXISTS tbl1(id INT, c2 INT, txt text, PRIMARY KEY (id), FULLTEXT INDEX full_idx1_tbl1(txt));";
30+
String createTableSQL = "CREATE TABLE IF NOT EXISTS tbl1(id INT, c2 INT, txt text, PRIMARY KEY (id), FULLTEXT INDEX full_idx1_tbl1(txt)) partition by key(id) partitions 3;";
3131
String createTTLTableSQL = "CREATE TABLE IF NOT EXISTS ttl_tbl1(id INT, c2 INT, txt text, expired_ts timestamp(6), PRIMARY KEY (id), FULLTEXT INDEX full_idx1_tbl1(txt)) TTL(expired_ts + INTERVAL 10 SECOND);;";
3232
String truncateTableSQL = "truncate table tbl1;";
3333
String truncateTTLTableSQL = "truncate table ttl_tbl1;";
@@ -326,11 +326,13 @@ public void testTTLInsert() throws Exception {
326326
}
327327

328328
@Test
329-
public void testFtsQuery() throws Exception {
329+
public void testFTSQuery() throws Exception {
330330
try {
331+
client.addRowKeyElement(tableName, new String[] {"id"});
332+
331333
//sync query
332334
QueryResultSet resultSet = client.query(tableName)
333-
.setSearchText("native")
335+
.setSearchText("oceanbase")
334336
.indexName("full_idx1_tbl1")
335337
.execute();
336338
while(resultSet.next()) {

0 commit comments

Comments
 (0)