[opt](inverted index) set support_phrase default true if parser is set (#38028)
## Proposed changes https://github.com/apache/doris/pull/37949 <!--Describe your changes.-->
This commit is contained in:
@ -73,9 +73,16 @@ public class Index implements Writable {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class IndexesProcNodeTest {
|
||||
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");
|
||||
|
||||
@ -74,7 +74,7 @@ suite("test_backup_restore_inverted_index", "backup_restore") {
|
||||
|
||||
def restore_index_comment = sql "SHOW CREATE TABLE ${dbName}.${tableName}"
|
||||
|
||||
assertTrue(restore_index_comment[0][1].contains("USING INVERTED PROPERTIES(\"parser\" = \"english\", \"lower_case\" = \"true\")"))
|
||||
assertTrue(restore_index_comment[0][1].contains("USING INVERTED PROPERTIES(\"parser\" = \"english\", \"lower_case\" = \"true\", \"support_phrase\" = \"true\")"))
|
||||
|
||||
result = sql "SELECT id, TOKENIZE(comment,'\"parser\"=\"english\"') as token FROM ${dbName}.${tableName}"
|
||||
assertEquals(result.size(), 2)
|
||||
|
||||
@ -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';"
|
||||
@ -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
|
||||
@ -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';"
|
||||
@ -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")
|
||||
|
||||
Reference in New Issue
Block a user