[Bug] score function return different result when run same query twice
- Dominant language
- Java
- Stars
- 15.9k
- Forks
- 3.9k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 520
Description
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) 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;
### What You Expected?
Should return the same result.
### How to Reproduce?
_No response_
### Anything Else?
_No response_
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Research direction
Start by running the provided CREATE TABLE, inverted-index setup, inserts, and repeated SELECT using SEARCH('name:"李鹏"') with score() and ORDER BY relevance DESC. Compare the top 10 rows and relevance values across executions; done means identical results are returned for the same query, or the nondeterministic behavior is isolated and covered by a reproducible test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100