Skip to content

[Bug] score function return different result when run same query twice #65118

Description

@yiguolei

Search before asking

  • I had searched in the issues and found no similar issues.

Version

doris 4.1.2

What's Wrong?

score function return different result when run same query twice.
sql
-- 1. 建表
CREATE TABLE doris_test_db.test_score_nd (
id INT NOT NULL,
name VARCHAR(100),
tag VARCHAR(50)
) DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 3
PROPERTIES('replication_num'='1');

-- 2. 建倒排索引(关键步骤)
CREATE INDEX idx_name ON doris_test_db.test_score_nd(name) USING INVERTED;

-- 3. 插数据
INSERT INTO doris_test_db.test_score_nd VALUES
(0,'李鹏','vip'),(1,'李鹏','normal'),(2,'李鹏','new'),(3,'李鹏','active'),
(4,'李鹏','dormant'),(5,'李鹏','staff'),(6,'李鹏','manager'),(7,'李鹏','vip'),
(8,'李鹏','normal'),(9,'李鹏','new'),(10,'李鹏','active'),(11,'李鹏','dormant'),
(12,'李鹏','staff'),(13,'李鹏','manager'),(14,'李鹏','vip'),(15,'李鹏','normal'),
(16,'李鹏','new'),(17,'李鹏','active'),(18,'李鹏','dormant'),(19,'李鹏','staff'),
(20,'李鹏','manager'),(21,'李鹏','vip'),(22,'李鹏','normal'),(23,'李鹏','new'),
(24,'李鹏','active'),(25,'李鹏','dormant'),(26,'李鹏','staff'),(27,'李鹏','manager'),
(28,'李鹏','vip'),(29,'李鹏','normal'),(30,'李鹏','new'),(31,'李鹏','active'),
(32,'李鹏','dormant'),(33,'李鹏','staff'),(34,'李鹏','manager'),(35,'李鹏','vip'),
(36,'李鹏','normal'),(37,'李鹏','new'),(38,'李鹏','active'),(39,'李鹏','dormant'),
(40,'李鹏','staff'),(41,'李鹏','manager'),(42,'李鹏','vip'),(43,'李鹏','normal'),
(44,'李鹏','new'),(45,'李鹏','active'),(46,'李鹏','dormant'),(47,'李鹏','staff'),
(48,'李鹏','manager'),(49,'李鹏','vip');

-- 4. 验证索引已生效
SHOW INDEX FROM doris_test_db.test_score_nd;

-- 5. 复现非确定性排序(多跑几次看结果是否不同)
SELECT id, name, tag, score() AS relevance
FROM doris_test_db.test_score_nd
WHERE SEARCH('name:"李鹏"')
ORDER BY relevance DESC
LIMIT 10;

Image

What You Expected?

Should return the same result.

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions