apache / apache/lucene

implement PositionLengthAttribute for all tokenstreams where its appropriate [LUCENE-3843]

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

Description

#4840 introduces PositionLengthAttribute, which extends the tokenstream API
from a sausage to a real graph.

Currently tokenstreams such as WordDelimiterFilter and SynonymsFilter theoretically
work at a graph level, but then serialize themselves to a sausage, for example:

wi-fi with WDF creates:
wi(posinc=1), fi(posinc=1), wifi(posinc=0)

So the lossiness is that the 'wifi' is simply stacked ontop of 'fi'

PositionLengthAttribute fixes this by allowing a token to declare how far it "spans",
so we don't lose any information.

While the indexer currently can only support sausages anyway (and for performance reasons,
this is probably just fine!), other tokenstream consumers such as queryparsers and suggesters
such as #4915 can actually make use of this information for better behavior.

So I think its ideal if the TokenStream API doesn't reflect the lossiness of the index format,
but instead keeps all information, and after #4840 is committed we should fix tokenstreams
to preserve this information for consumers that can use it.

---
Migrated from [LUCENE-3843](https://issues.apache.org/jira/browse/LUCENE-3843) by Robert Muir (@rmuir), 6 votes, updated May 09 2016
Linked issues:
- #4917
- #4840

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the PositionLengthAttribute work in #4840 and the related suggestion issue #4917, then inspect tokenstreams such as WordDelimiterFilter and SynonymsFilter named here. Done means appropriate tokenstreams preserve position-length information for consumers that can use it, but the issue does not identify the complete set of classes or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.