[Enhancement](inverted index) use conjunction query to accelerate fulltext equal query (#24373)

This commit is contained in:
airborne12
2023-09-15 15:34:57 +08:00
committed by GitHub
parent 3c18ed4e86
commit 6dbe07bd3b
3 changed files with 62 additions and 6 deletions

View File

@ -280,7 +280,8 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run
roaring::Roaring query_match_bitmap;
bool null_bitmap_already_read = false;
if (query_type == InvertedIndexQueryType::MATCH_PHRASE_QUERY ||
query_type == InvertedIndexQueryType::MATCH_ALL_QUERY) {
query_type == InvertedIndexQueryType::MATCH_ALL_QUERY ||
query_type == InvertedIndexQueryType::EQUAL_QUERY) {
std::wstring wstr_tokens;
for (auto& token : analyse_result) {
wstr_tokens += token;
@ -381,11 +382,6 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run
query_match_bitmap |= *term_match_bitmap;
break;
}
case InvertedIndexQueryType::EQUAL_QUERY: {
SCOPED_RAW_TIMER(&stats->inverted_index_query_bitmap_op_timer);
query_match_bitmap &= *term_match_bitmap;
break;
}
default: {
return Status::Error<ErrorCode::INVERTED_INDEX_NOT_SUPPORTED>(
"fulltext query do not support query type other than match.");

View File

@ -0,0 +1,8 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
2 I am a person
-- !sql --
1 I am the person
2 I am a person

View File

@ -0,0 +1,52 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
suite("test_equal_on_fulltext", "p0"){
// prepare test table
def timeout = 60000
def delta_time = 1000
def alter_res = "null"
def useTime = 0
def indexTblName = "test_equal_on_fulltext"
sql "DROP TABLE IF EXISTS ${indexTblName}"
// create 1 replica table
sql """
CREATE TABLE IF NOT EXISTS ${indexTblName}(
`id`int(11)NULL,
`c` text NULL,
INDEX c_idx(`c`) USING INVERTED PROPERTIES("parser"="unicode") COMMENT ''
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES(
"replication_allocation" = "tag.location.default: 1"
);
"""
def var_result = sql "show variables"
logger.info("show variales result: " + var_result )
sql "INSERT INTO $indexTblName VALUES (1, 'I am the person'), (2, 'I am a person'), (3, 'I am your person');"
qt_sql "SELECT * FROM $indexTblName WHERE c = 'I am a person' ORDER BY id;"
qt_sql "SELECT * FROM $indexTblName WHERE c in ('I am a person', 'I am the person') ORDER BY id;"
}