manticoresoftware / manticoresoftware/manticoresearch
Incorrect lcs calculation with quorum operator
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12k
- Forks
- 642
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 47
Description
**Describe the bug**
LCS is calculated incorrectly, when quorum operator is present, even if it is removed later (words amount equal to quorum operator value).
**To Reproduce**
Steps to reproduce the behavior:
1. Create index like in tutorial [here](https://play.manticoresearch.com/csv/)
2. Run two queries:
```Select id, weight() from movies where id = 17 and match('"prince" | "caspian"') option ranker=expr('sum(lcs)');```
3. ```Select id, weight() from movies where id = 17 and match('"prince"/1 | "caspian"/1') option ranker=expr('sum(lcs)');```
4. I get different LCS value.
5. If I look at SHOW PLAN, i see the following:
```Case without quorum
OR(
AND(KEYWORD(prince, querypos=1)),
AND(KEYWORD(caspian, querypos=2)))
Case with quorum
OR(
AND(KEYWORD(prince, querypos=1)),
AND(KEYWORD(caspian, querypos=3)))
```
They differ in querypos of word __caspian__
**Expected behavior**
As quorum operator is redundant here, I expect ommiting it and getting same results
**Describe the environment:**
- Manticore playground
**Messages from log files:**
Messages from searchd.log and query.log (if applicable).
**Additional context**
Add any other context about the problem here.
In case you've faced a crash what `indextool --check` returns.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two SQL queries against the tutorial movie index and compare SHOW PLAN output, especially the querypos assigned to “caspian.” Trace the quorum operator’s effect on query positions and LCS calculation; done means the redundant quorum form produces the same query plan positions and LCS value as the form without it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100