From eb0b8a2426a8e43c8ba636d9e3f12e403004a423 Mon Sep 17 00:00:00 2001 From: airborne12 Date: Mon, 19 Oct 2026 14:58:43 +0800 Subject: [PATCH] [fix](be) Backport regexp and wildcard BM25 scoring to branch-4.1 Backport #69052 through the existing query_v2 term scorers. Sum BM25 contributions for scored expansions and retain the unscored bitmap path. Add independent term-score assertions and V2/V3 SQL regression coverage. (cherry picked from commit 34a123b85da6ffc4990157820211dd08462744ec) --- .../query_v2/regexp_query/regexp_weight.cpp | 50 +++ .../query_v2/regexp_query/regexp_weight.h | 6 +- .../inverted/query_v2/regexp_query_test.cpp | 61 +++- .../inverted/query_v2/wildcard_query_test.cpp | 72 +++- .../test_search_score_regexp_wildcard.out | 337 ++++++++++++++++++ .../test_search_score_regexp_wildcard.groovy | 80 +++++ 6 files changed, 591 insertions(+), 15 deletions(-) create mode 100644 regression-test/data/search/test_search_score_regexp_wildcard.out create mode 100644 regression-test/suites/search/test_search_score_regexp_wildcard.groovy diff --git a/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.cpp b/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.cpp index 5ecfad0d3ae14a..e2576724ab47e8 100644 --- a/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.cpp +++ b/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.cpp @@ -34,12 +34,18 @@ #include #include +#include #include +#include #include "storage/index/inverted/query_v2/bit_set_query/bit_set_scorer.h" #include "storage/index/inverted/query_v2/const_score_query/const_score_scorer.h" #include "storage/index/inverted/query_v2/nullable_scorer.h" +#include "storage/index/inverted/query_v2/score_combiner.h" #include "storage/index/inverted/query_v2/segment_postings.h" +#include "storage/index/inverted/query_v2/term_query/term_scorer.h" +#include "storage/index/inverted/query_v2/union/buffered_union.h" +#include "storage/index/inverted/similarity/bm25_similarity.h" #include "storage/index/inverted/util/string_helper.h" #include "util/hyperscan_util.h" @@ -110,6 +116,10 @@ ScorerPtr RegexpWeight::regexp_scorer(const QueryExecutionContext& context, } auto reader = lookup_reader(_field, context, binding_key); + if (_enable_scoring) { + return scored_terms_scorer(reader.get(), context, binding_key, matching_terms); + } + auto doc_bitset = std::make_shared(); for (const auto& term : matching_terms) { auto segment_postings = @@ -126,6 +136,46 @@ ScorerPtr RegexpWeight::regexp_scorer(const QueryExecutionContext& context, return const_score; } +ScorerPtr RegexpWeight::scored_terms_scorer(lucene::index::IndexReader* reader, + const QueryExecutionContext& context, + const std::string& binding_key, + const std::vector& matching_terms) { + // Expanded terms are not collected in collection statistics, so use reader statistics. + const auto num_docs = reader->maxDoc(); + DORIS_CHECK_GT(num_docs, 0); + const auto total_term_freq = reader->sumTotalTermFreq(_field.c_str()); + // Without norms, postings use a document length of one. + const float avgdl = static_cast(total_term_freq.value_or(num_docs)) / num_docs; + DORIS_CHECK_GT(avgdl, 0.0F); + + std::vector term_scorers; + term_scorers.reserve(matching_terms.size()); + auto logical_field = logical_field_or_fallback(context, binding_key, _field); + for (const auto& term : matching_terms) { + Term lucene_term(_field.c_str(), term.c_str()); + const int32_t doc_freq = reader->docFreq(&lucene_term); + if (doc_freq == 0) { + continue; + } + const auto idf = static_cast( + std::log1p((static_cast(num_docs) - doc_freq + 0.5) / (doc_freq + 0.5))); + auto similarity = std::make_shared(idf, avgdl); + auto posting = + create_term_posting(reader, _field, term, true, similarity, _context->io_ctx); + if (posting) { + term_scorers.emplace_back(std::make_shared( + std::move(posting), std::move(similarity), logical_field)); + } + } + if (term_scorers.empty()) { + return std::make_shared(); + } + if (term_scorers.size() == 1) { + return std::move(term_scorers.front()); + } + return make_buffered_union(term_scorers, std::make_shared()); +} + std::optional RegexpWeight::get_regex_prefix(const std::string& pattern) { DBUG_EXECUTE_IF("RegexpQuery.get_regex_prefix", { return std::nullopt; }); diff --git a/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.h b/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.h index f8b1a0ba9faf1a..6ef13c71fa5521 100644 --- a/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.h +++ b/be/src/storage/index/inverted/query_v2/regexp_query/regexp_weight.h @@ -35,6 +35,10 @@ class RegexpWeight : public Weight { private: ScorerPtr regexp_scorer(const QueryExecutionContext& context, const std::string& binding_key); + ScorerPtr scored_terms_scorer(lucene::index::IndexReader* reader, + const QueryExecutionContext& context, + const std::string& binding_key, + const std::vector& matching_terms); std::optional get_regex_prefix(const std::string& pattern); void collect_matching_terms(const QueryExecutionContext& context, @@ -46,7 +50,7 @@ class RegexpWeight : public Weight { std::wstring _field; std::string _pattern; - [[maybe_unused]] bool _enable_scoring = false; + bool _enable_scoring = false; bool _nullable = true; // Set to 0 to disable limit (ES has no default limit for prefix queries) // The limit prevents collecting too many terms, but can cause incorrect results diff --git a/be/test/storage/index/inverted/query_v2/regexp_query_test.cpp b/be/test/storage/index/inverted/query_v2/regexp_query_test.cpp index aea4ed627ed643..ed02ac578d35df 100644 --- a/be/test/storage/index/inverted/query_v2/regexp_query_test.cpp +++ b/be/test/storage/index/inverted/query_v2/regexp_query_test.cpp @@ -28,6 +28,7 @@ #include "storage/index/index_query_context.h" #include "storage/index/inverted/analyzer/custom_analyzer.h" #include "storage/index/inverted/query_v2/regexp_query/regexp_weight.h" +#include "storage/index/inverted/query_v2/term_query/term_query.h" #include "storage/index/inverted/util/string_helper.h" CL_NS_USE(search) @@ -58,10 +59,13 @@ class RegexpQueryV2Test : public testing::Test { private: void create_test_index(const std::string& field_name, const std::string& dir) { std::vector test_data = { - "apple123", "apple456", "banana789", "test123abc", "pattern456", - "regex999", "match123", "search456", "prefix123", "suffix789", - "apple_test", "banana_data", "test_pattern", "data_regex", "apple_banana", - "test_match", "pattern_test", "prefix_suffix", "abc123xyz", "def456ghi"}; + "apple123", "apple456", "banana789", + "test123abc", "pattern456", "regex999", + "match123", "search456", "prefix123", + "suffix789", "apple_test", "banana_data", + "test_pattern", "data_regex", "apple_banana", + "test_match", "pattern_test", "prefix_suffix", + "abc123xyz", "def456ghi", "apple789 apple789 apple456"}; CustomAnalyzerConfig::Builder builder; builder.with_tokenizer_config("standard", {}); @@ -167,6 +171,53 @@ TEST_F(RegexpQueryV2Test, test_regexp_query_with_scoring) { ASSERT_NE(regexp_weight, nullptr); } +TEST_F(RegexpQueryV2Test, test_regexp_query_scores_matching_terms) { + auto context = std::make_shared(); + context->collection_statistics = std::make_shared(); + context->collection_similarity = std::make_shared(); + + auto* dir = FSDirectory::getDirectory(kTestDir.c_str()); + auto reader_holder = make_shared_reader(lucene::index::IndexReader::open(dir, true)); + ASSERT_NE(reader_holder, nullptr); + + std::wstring field = StringHelper::to_wstring("content"); + auto query = std::make_shared(context, field, "apple.*"); + auto weight = query->weight(true); + + query_v2::QueryExecutionContext exec_ctx; + exec_ctx.segment_num_rows = reader_holder->maxDoc(); + exec_ctx.readers = {reader_holder}; + exec_ctx.field_reader_bindings.emplace(field, reader_holder); + + auto statistics = context->collection_statistics; + statistics->_total_num_docs = reader_holder->maxDoc(); + statistics->_total_num_tokens[field] = + reader_holder->sumTotalTermFreq(field.c_str()).value_or(reader_holder->maxDoc()); + for (const auto* term : {L"apple123", L"apple789", L"apple456"}) { + Term lucene_term(field.c_str(), term); + statistics->_term_doc_freqs[field][term] = reader_holder->docFreq(&lucene_term); + } + auto term_score = [&](const wchar_t* term, uint32_t doc_id) { + auto term_query = std::make_shared(context, field, term); + auto term_scorer = term_query->weight(true)->scorer(exec_ctx); + EXPECT_EQ(term_scorer->seek(doc_id), doc_id); + return term_scorer->score(); + }; + + auto scorer = weight->scorer(exec_ctx); + ASSERT_EQ(scorer->seek(0), 0); + float single_term_score = scorer->score(); + EXPECT_NE(single_term_score, 1.0F); + EXPECT_FLOAT_EQ(single_term_score, term_score(L"apple123", 0)); + uint32_t last_doc = reader_holder->maxDoc() - 1; + ASSERT_EQ(scorer->seek(last_doc), last_doc); + EXPECT_GT(scorer->score(), single_term_score); + EXPECT_NEAR(scorer->score(), + term_score(L"apple789", last_doc) + term_score(L"apple456", last_doc), 1e-5F); + + _CLDECDELETE(dir); +} + // Test regexp query execution TEST_F(RegexpQueryV2Test, test_regexp_query_execution) { auto context = std::make_shared(); @@ -574,7 +625,7 @@ TEST_F(RegexpQueryV2Test, test_make_exact_match_wildcard_pattern) { doc = scorer->advance(); } - EXPECT_EQ(result.cardinality(), 20); + EXPECT_EQ(result.cardinality(), 21); _CLDECDELETE(dir); } diff --git a/be/test/storage/index/inverted/query_v2/wildcard_query_test.cpp b/be/test/storage/index/inverted/query_v2/wildcard_query_test.cpp index af119cdd260217..3807a2787dbe0f 100644 --- a/be/test/storage/index/inverted/query_v2/wildcard_query_test.cpp +++ b/be/test/storage/index/inverted/query_v2/wildcard_query_test.cpp @@ -27,6 +27,7 @@ #include "common/status.h" #include "storage/index/index_query_context.h" #include "storage/index/inverted/analyzer/custom_analyzer.h" +#include "storage/index/inverted/query_v2/term_query/term_query.h" #include "storage/index/inverted/query_v2/wildcard_query/wildcard_weight.h" #include "storage/index/inverted/util/string_helper.h" @@ -57,14 +58,20 @@ class WildcardQueryV2Test : public testing::Test { private: void create_test_index(const std::string& field_name, const std::string& dir) { - std::vector test_data = { - "apple", "application", "apply", "apricot", "banana", "band", - "bandana", "can", "candy", "cat", "catalog", "dog", - "document", "door", "hello", "help", "helpful", "test", - "testing", "testcase", "wildcard", "wild", "wilderness", "card", - "cardboard", "abc", "abcd", "abcde", "prefix123", "123suffix", - "pre123", "123suf", "both123both", "star", "start", "started", - "starter", "question", "quest", "query", "queries"}; + std::vector test_data = {"apple", "application", "apply", + "apricot", "banana", "band", + "bandana", "can", "candy", + "cat", "catalog", "dog", + "document", "door", "hello", + "help", "helpful", "test", + "testing", "testcase", "wildcard", + "wild", "wilderness", "card", + "cardboard", "abc", "abcd", + "abcde", "prefix123", "123suffix", + "pre123", "123suf", "both123both", + "star", "start", "started", + "starter", "question", "quest", + "query", "queries", "test test testing"}; CustomAnalyzerConfig::Builder builder; builder.with_tokenizer_config("standard", {}); @@ -155,6 +162,53 @@ TEST_F(WildcardQueryV2Test, test_wildcard_query_with_scoring) { ASSERT_NE(wildcard_weight, nullptr); } +TEST_F(WildcardQueryV2Test, test_wildcard_query_scores_matching_terms) { + auto context = std::make_shared(); + context->collection_statistics = std::make_shared(); + context->collection_similarity = std::make_shared(); + + auto* dir = FSDirectory::getDirectory(kTestDir.c_str()); + auto reader_holder = make_shared_reader(lucene::index::IndexReader::open(dir, true)); + ASSERT_NE(reader_holder, nullptr); + + std::wstring field = StringHelper::to_wstring("field"); + auto query = std::make_shared(context, field, "test*"); + auto weight = query->weight(true); + + query_v2::QueryExecutionContext exec_ctx; + exec_ctx.segment_num_rows = reader_holder->maxDoc(); + exec_ctx.readers = {reader_holder}; + exec_ctx.field_reader_bindings.emplace(field, reader_holder); + + auto statistics = context->collection_statistics; + statistics->_total_num_docs = reader_holder->maxDoc(); + statistics->_total_num_tokens[field] = + reader_holder->sumTotalTermFreq(field.c_str()).value_or(reader_holder->maxDoc()); + for (const auto* term : {L"test", L"testing"}) { + Term lucene_term(field.c_str(), term); + statistics->_term_doc_freqs[field][term] = reader_holder->docFreq(&lucene_term); + } + auto term_score = [&](const wchar_t* term, uint32_t doc_id) { + auto term_query = std::make_shared(context, field, term); + auto term_scorer = term_query->weight(true)->scorer(exec_ctx); + EXPECT_EQ(term_scorer->seek(doc_id), doc_id); + return term_scorer->score(); + }; + + auto scorer = weight->scorer(exec_ctx); + ASSERT_EQ(scorer->seek(17), 17); + float single_term_score = scorer->score(); + EXPECT_NE(single_term_score, 1.0F); + EXPECT_FLOAT_EQ(single_term_score, term_score(L"test", 17)); + uint32_t last_doc = reader_holder->maxDoc() - 1; + ASSERT_EQ(scorer->seek(last_doc), last_doc); + EXPECT_GT(scorer->score(), single_term_score); + EXPECT_NEAR(scorer->score(), term_score(L"test", last_doc) + term_score(L"testing", last_doc), + 1e-5F); + + _CLDECDELETE(dir); +} + // Test wildcard query with asterisk prefix pattern TEST_F(WildcardQueryV2Test, test_wildcard_query_prefix_pattern) { auto context = std::make_shared(); @@ -524,4 +578,4 @@ TEST_F(WildcardQueryV2Test, test_wildcard_query_move_semantics) { ASSERT_NE(weight2, nullptr); } -} // namespace doris::segment_v2 \ No newline at end of file +} // namespace doris::segment_v2 diff --git a/regression-test/data/search/test_search_score_regexp_wildcard.out b/regression-test/data/search/test_search_score_regexp_wildcard.out new file mode 100644 index 00000000000000..393a5781dab564 --- /dev/null +++ b/regression-test/data/search/test_search_score_regexp_wildcard.out @@ -0,0 +1,337 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !V2_standard_unscored_regexp -- +1 +2 +3 +4 +7 +8 + +-- !V2_standard_unscored_wildcard -- +1 +2 +3 +4 +7 +8 + +-- !V2_standard_false_regexp -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V2_standard_false_wildcard -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V2_standard_false_terms -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V2_standard_false_ascending -- +1 0.584433 +2 0.655108 +3 1.120813 +7 1.248584 +4 1.312985 +8 2.087193 + +-- !V2_standard_false_missing -- + +-- !V2_standard_true_regexp -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V2_standard_true_wildcard -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V2_standard_true_terms -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V2_standard_true_ascending -- +1 0.584433 +2 0.655108 +3 1.120813 +7 1.248584 +4 1.312985 +8 2.087193 + +-- !V2_standard_true_missing -- + +-- !V2_none_unscored_regexp -- +1 +2 +3 +4 +7 +8 + +-- !V2_none_unscored_wildcard -- +1 +2 +3 +4 +7 +8 + +-- !V2_none_false_regexp -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_false_wildcard -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_false_terms -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_false_ascending -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_false_missing -- + +-- !V2_none_true_regexp -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_true_wildcard -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_true_terms -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_true_ascending -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V2_none_true_missing -- + +-- !V3_standard_unscored_regexp -- +1 +2 +3 +4 +7 +8 + +-- !V3_standard_unscored_wildcard -- +1 +2 +3 +4 +7 +8 + +-- !V3_standard_false_regexp -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V3_standard_false_wildcard -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V3_standard_false_terms -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V3_standard_false_ascending -- +1 0.584433 +2 0.655108 +3 1.120813 +7 1.248584 +4 1.312985 +8 2.087193 + +-- !V3_standard_false_missing -- + +-- !V3_standard_true_regexp -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V3_standard_true_wildcard -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V3_standard_true_terms -- +8 2.087193 +4 1.312985 +7 1.248584 +3 1.120813 +2 0.655108 +1 0.584433 + +-- !V3_standard_true_ascending -- +1 0.584433 +2 0.655108 +3 1.120813 +7 1.248584 +4 1.312985 +8 2.087193 + +-- !V3_standard_true_missing -- + +-- !V3_none_unscored_regexp -- +1 +2 +3 +4 +7 +8 + +-- !V3_none_unscored_wildcard -- +1 +2 +3 +4 +7 +8 + +-- !V3_none_false_regexp -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_false_wildcard -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_false_terms -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_false_ascending -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_false_missing -- + +-- !V3_none_true_regexp -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_true_wildcard -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_true_terms -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_true_ascending -- +1 1.791759 +2 1.791759 +3 1.791759 +4 1.791759 +7 1.791759 +8 1.791759 + +-- !V3_none_true_missing -- + diff --git a/regression-test/suites/search/test_search_score_regexp_wildcard.groovy b/regression-test/suites/search/test_search_score_regexp_wildcard.groovy new file mode 100644 index 00000000000000..01cd72c70a7324 --- /dev/null +++ b/regression-test/suites/search/test_search_score_regexp_wildcard.groovy @@ -0,0 +1,80 @@ +// 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_search_score_regexp_wildcard", "p0") { + sql "set enable_common_expr_pushdown = true" + sql "set enable_inverted_index_query = true" + + def scoredQuery = { predicate, direction, limit -> + """ + SELECT id, ROUND(bm25_score, 6) + FROM ( + SELECT id, score() AS bm25_score + FROM test_search_score_regexp_wildcard + WHERE ${predicate} + ORDER BY bm25_score ${direction} LIMIT ${limit} + ) hits + ORDER BY bm25_score ${direction}, id + """ + } + for (String storageFormat : ["V2", "V3"]) { + for (String parser : ["standard", "none"]) { + sql "DROP TABLE IF EXISTS test_search_score_regexp_wildcard" + sql """ + CREATE TABLE test_search_score_regexp_wildcard ( + id INT NOT NULL, + content STRING NULL, + INDEX idx_content(content) USING INVERTED PROPERTIES("parser" = "${parser}") + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default:1", + "inverted_index_storage_format" = "${storageFormat}" + ) + """ + sql """ + INSERT INTO test_search_score_regexp_wildcard VALUES + (1, 'apple'), (2, 'apple apple apple'), (3, 'application'), + (4, 'apple application'), (5, 'banana'), (6, NULL), + (7, 'apple application apple'), (8, 'apply apple') + """ + sql "sync" + String regexp = "search('content:/app.*/', '{\"mode\":\"lucene\"}')" + String wildcard = "search('content:*pp*', '{\"mode\":\"lucene\"}')" + String terms = parser == "standard" + ? "search('content:apple OR content:application OR content:apply', '{\"mode\":\"lucene\"}')" + : "search('content:EXACT(apple) OR content:EXACT(apple apple apple) OR content:EXACT(application) OR content:EXACT(apple application) OR content:EXACT(apple application apple) OR content:EXACT(apply apple)', '{\"mode\":\"standard\"}')" + String label = "${storageFormat}_${parser}" + quickTest("${label}_unscored_regexp", """ + SELECT id FROM test_search_score_regexp_wildcard WHERE ${regexp} ORDER BY id + """) + quickTest("${label}_unscored_wildcard", """ + SELECT id FROM test_search_score_regexp_wildcard WHERE ${wildcard} ORDER BY id + """) + for (boolean wand : [false, true]) { + sql "set enable_inverted_index_wand_query = ${wand}" + quickTest("${label}_${wand}_regexp", scoredQuery(regexp, "DESC", 100)) + quickTest("${label}_${wand}_wildcard", scoredQuery(wildcard, "DESC", 100)) + quickTest("${label}_${wand}_terms", scoredQuery(terms, "DESC", 100)) + quickTest("${label}_${wand}_ascending", scoredQuery(regexp, "ASC", 100)) + quickTest("${label}_${wand}_missing", scoredQuery( + "search('content:/missing.*/', '{\"mode\":\"lucene\"}')", "DESC", 100)) + } + } + } +}