Skip to content

Commit 1d3838d

Browse files
committed
[fix](inverted index) Align phrase support defaults across FE and BE
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: FE documented phrase support as enabled by default, but an inverted index without parser properties omitted the setting from its metadata. BE then interpreted the missing setting as disabled and wrote a docs-only SNII index. Persist the default for new inverted indexes and align the BE fallback for older metadata. ### Release note Inverted indexes now enable phrase positions by default when support_phrase is omitted. Explicit support_phrase=false remains unchanged. ### Check List (For Author) - Test: FE unit test for default and explicit phrase support. - Behavior changed: Yes, new inverted indexes with no phrase property write positions. - Does this need documentation: No
1 parent 7e63fc9 commit 1d3838d

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

‎be/src/storage/index/inverted/analysis/inverted_index_parser.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ std::string get_parser_phrase_support_string_from_properties(
121121
it != properties.end()) {
122122
return it->second;
123123
}
124-
return INVERTED_INDEX_PARSER_PHRASE_SUPPORT_NO;
124+
return INVERTED_INDEX_PARSER_PHRASE_SUPPORT_YES;
125125
}
126126

127127
bool should_write_index_norms(const TabletIndex& index_meta) {

‎be/test/storage/index/inverted/analysis/inverted_index_parser_test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ TEST_F(InvertedIndexParserTest, TestGetParserPhraseSupportStringFromProperties)
128128

129129
// Test with empty properties
130130
EXPECT_EQ(get_parser_phrase_support_string_from_properties(properties),
131-
INVERTED_INDEX_PARSER_PHRASE_SUPPORT_NO);
131+
INVERTED_INDEX_PARSER_PHRASE_SUPPORT_YES);
132132

133133
// Test with phrase support key present
134134
properties[INVERTED_INDEX_PARSER_PHRASE_SUPPORT_KEY] = INVERTED_INDEX_PARSER_PHRASE_SUPPORT_YES;

‎fe/fe-catalog/src/main/java/org/apache/doris/catalog/Index.java‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,12 @@ public Index(long indexId, String indexName, List<String> columns,
7474
this.properties = properties == null ? Maps.newHashMap() : Maps.newHashMap(properties);
7575
this.comment = comment;
7676
if (indexType == IndexType.INVERTED) {
77-
if (this.properties != null && !this.properties.isEmpty()) {
78-
if (this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_PARSER_KEY)
79-
|| this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_PARSER_KEY_ALIAS)
80-
|| this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_ANALYZER_NAME_KEY)
81-
|| this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_NORMALIZER_NAME_KEY)) {
82-
String supportPhraseKey = InvertedIndexProperties
83-
.INVERTED_INDEX_SUPPORT_PHRASE_KEY;
84-
if (!this.properties.containsKey(supportPhraseKey)) {
85-
this.properties.put(supportPhraseKey, "true");
86-
}
87-
}
88-
if (this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_PARSER_KEY)
89-
|| this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_PARSER_KEY_ALIAS)) {
90-
String lowerCaseKey = InvertedIndexProperties.INVERTED_INDEX_PARSER_LOWERCASE_KEY;
91-
if (!this.properties.containsKey(lowerCaseKey)) {
92-
this.properties.put(lowerCaseKey, "true");
93-
}
77+
this.properties.putIfAbsent(InvertedIndexProperties.INVERTED_INDEX_SUPPORT_PHRASE_KEY, "true");
78+
if (this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_PARSER_KEY)
79+
|| this.properties.containsKey(InvertedIndexProperties.INVERTED_INDEX_PARSER_KEY_ALIAS)) {
80+
String lowerCaseKey = InvertedIndexProperties.INVERTED_INDEX_PARSER_LOWERCASE_KEY;
81+
if (!this.properties.containsKey(lowerCaseKey)) {
82+
this.properties.put(lowerCaseKey, "true");
9483
}
9584
}
9685
}

‎fe/fe-core/src/test/java/org/apache/doris/catalog/IndexTest.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@
2424

2525
import java.util.ArrayList;
2626
import java.util.List;
27+
import java.util.Map;
2728

2829
public class IndexTest {
2930

31+
@Test
32+
public void testInvertedIndexPersistsDefaultPhraseSupport() {
33+
Index exact = new Index(1, "exact", List.of("col"), IndexType.INVERTED, Map.of(), "");
34+
Assertions.assertEquals("true", exact.getProperties().get("support_phrase"));
35+
36+
Index disabled = new Index(2, "disabled", List.of("col"), IndexType.INVERTED,
37+
Map.of("support_phrase", "false"), "");
38+
Assertions.assertEquals("false", disabled.getProperties().get("support_phrase"));
39+
40+
Index bitmap = new Index(3, "bitmap", List.of("col"), IndexType.BITMAP, Map.of(), "");
41+
Assertions.assertFalse(bitmap.getProperties().containsKey("support_phrase"));
42+
}
43+
3044
@Test
3145
public void testGetColumnUniqueIds() {
3246
// Create test columns with unique IDs

0 commit comments

Comments
 (0)