apache / apache/lucene

Remove alphabetically ordered completions from FSTCompletion [LUCENE-10540]

Open
#11,576 0 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Major type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

The code cheats internally by sorting completions that are always weight-ordered. If this is needed, it should be done up the call stack, not in FSTCompletion - this provides an illusion of something that doesn't exist and is potentially quite expensive to compute.

```Java
if (!higherWeightsFirst && rootArcs.length > 1) {
// We could emit a warning here (?). An optimal strategy for
// alphabetically sorted
// suggestions would be to add them with a constant weight -- this saves
// unnecessary
// traversals and sorting.
return lookup(key).sorted().limit(num).collect(Collectors.toList());
} else {
return lookup(key).limit(num).collect(Collectors.toList());
}
```

---
Migrated from [LUCENE-10540](https://issues.apache.org/jira/browse/LUCENE-10540) by Dawid Weiss (@dweiss)
Linked issues:
- #11575

Contributor guide

Open the contributing guide

Research direction

Start in FSTCompletion and inspect the lookup path containing the alphabetically ordered completion branch. Determine which callers still require alphabetical ordering and whether that responsibility belongs higher in the call stack; done means FSTCompletion no longer performs this ordering while required caller behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.