Skip to content

Commit

Permalink
[opt](inverted index) set support_phrase default true if parser is set
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzxl1993 authored and weixingyu12 committed Jul 28, 2024
1 parent 6c77691 commit 6be814e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
13 changes: 10 additions & 3 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ public Index(long indexId, String indexName, List<String> columns,
this.comment = comment;
if (indexType == IndexDef.IndexType.INVERTED) {
if (this.properties != null && !this.properties.isEmpty()) {
String key = InvertedIndexUtil.INVERTED_INDEX_PARSER_LOWERCASE_KEY;
if (!properties.containsKey(key)) {
this.properties.put(key, "true");
if (this.properties.containsKey(InvertedIndexUtil.INVERTED_INDEX_PARSER_KEY)) {
String lowerCaseKey = InvertedIndexUtil.INVERTED_INDEX_PARSER_LOWERCASE_KEY;
if (!properties.containsKey(lowerCaseKey)) {
this.properties.put(lowerCaseKey, "true");
}
String supportPhraseKey = InvertedIndexUtil
.INVERTED_INDEX_SUPPORT_PHRASE_KEY;
if (!properties.containsKey(supportPhraseKey)) {
this.properties.put(supportPhraseKey, "true");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testFetchResult() throws AnalysisException {
Assert.assertEquals(procResult.getRows().get(1).get(5), "col_2");
Assert.assertEquals(procResult.getRows().get(1).get(11), "INVERTED");
Assert.assertEquals(procResult.getRows().get(1).get(12), "inverted index on col_2");
Assert.assertEquals(procResult.getRows().get(1).get(13), "(\"parser\" = \"unicode\", \"lower_case\" = \"true\")");
Assert.assertEquals(procResult.getRows().get(1).get(13), "(\"parser\" = \"unicode\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")");

Assert.assertEquals(procResult.getRows().get(2).get(0), "tbl_test_indexes_proc");
Assert.assertEquals(procResult.getRows().get(2).get(1), "3");
Expand Down
10 changes: 5 additions & 5 deletions regression-test/suites/index_p0/test_index_meta.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ suite("index_meta", "p0") {
assertEquals(show_result[1][4], "name")
assertEquals(show_result[1][10], "INVERTED")
assertEquals(show_result[1][11], "index for name")
assertEquals(show_result[1][12], "(\"parser\" = \"none\", \"lower_case\" = \"true\")")
assertEquals(show_result[1][12], "(\"parser\" = \"none\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")")

// add index on column description
sql "create index idx_desc on ${tableName}(description) USING INVERTED PROPERTIES(\"parser\"=\"standard\") COMMENT 'index for description';"
Expand All @@ -90,12 +90,12 @@ suite("index_meta", "p0") {
assertEquals(show_result[1][4], "name")
assertEquals(show_result[1][10], "INVERTED")
assertEquals(show_result[1][11], "index for name")
assertEquals(show_result[1][12], "(\"parser\" = \"none\", \"lower_case\" = \"true\")")
assertEquals(show_result[1][12], "(\"parser\" = \"none\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")")
assertEquals(show_result[2][2], "idx_desc")
assertEquals(show_result[2][4], "description")
assertEquals(show_result[2][10], "INVERTED")
assertEquals(show_result[2][11], "index for description")
assertEquals(show_result[2][12], "(\"parser\" = \"standard\", \"lower_case\" = \"true\")")
assertEquals(show_result[2][12], "(\"parser\" = \"standard\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")")

// drop index
// add index on column description
Expand All @@ -114,7 +114,7 @@ suite("index_meta", "p0") {
assertEquals(show_result[1][4], "description")
assertEquals(show_result[1][10], "INVERTED")
assertEquals(show_result[1][11], "index for description")
assertEquals(show_result[1][12], "(\"parser\" = \"standard\", \"lower_case\" = \"true\")")
assertEquals(show_result[1][12], "(\"parser\" = \"standard\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")")

// add index on column description
sql "create index idx_name on ${tableName}(name) USING INVERTED COMMENT 'new index for name';"
Expand All @@ -133,7 +133,7 @@ suite("index_meta", "p0") {
assertEquals(show_result[1][4], "description")
assertEquals(show_result[1][10], "INVERTED")
assertEquals(show_result[1][11], "index for description")
assertEquals(show_result[1][12], "(\"parser\" = \"standard\", \"lower_case\" = \"true\")")
assertEquals(show_result[1][12], "(\"parser\" = \"standard\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")")
assertEquals(show_result[2][2], "idx_name")
assertEquals(show_result[2][4], "name")
assertEquals(show_result[2][10], "INVERTED")
Expand Down

0 comments on commit 6be814e

Please sign in to comment.