HyphenationCompoundWordTokenFilter fixed token position and preserves original token
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
### Description
The `HyphenationCompoundWordTokenFilter` is the recommended decompounder for Germanic languages, recommended by Elastic [Elasticsearch Docs](https://www.elastic.co/guide/en/elasticsearch/reference/8.18/analysis-hyp-decomp-tokenfilter.html).
Although the decompounding doesn't work as expected for my use case. Let me explain with an example:
1. The user searches for 'Sommerkleid' in a webshop (German for Summer dress)
2. Decompounding the word 'Sommerkleid' will return 'sommerkleid', 'sommer' and 'kleid'. (The positions of all 3 tokens are `position: 0`)
3. Since all tokens are on position 0, the customer gets products that container 'sommer' OR 'kleid' OR 'sommerkleid', although the customer was searching for both and not either terms. Leading to random products that are not a 'kleid', but are categorized as 'sommer' products.
Ideally there would be two extra properties to;
1. exclude initial token from output (default false for backwards compatibility)
2. increase position for split tokens ('sommer' would be pos: 0, 'kleid' would be pos: 1)
Would this be possible to add? I already saw a related issue from 5 years ago -> https://github.com/apache/lucene/issues/10625, although was not implemented back then.
Contributor guide
Research direction
Start by reading HyphenationCompoundWordTokenFilter and the related issue 10625 to understand the existing token-position behavior. Done means supporting optional exclusion of the original token and optional position increments for split tokens while preserving backward-compatible defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100