SOLR-18362: remove org.apache.solr.spelling.Token - #4812
SOLR-18362: remove org.apache.solr.spelling.Token#4812serhiy-bzhezytskyy wants to merge 1 commit into
Conversation
Replaces the deprecated Token (a Lucene PackedTokenAttributeImpl subclass) with real TokenStream consumption throughout the spellchecker API, using Lucene's own attribute interfaces. SpellingResult/mergeSuggestions still need one plain value type (SpellCheckToken) to key suggestions from remote-shard responses, where there's no stream to read from.
|
is this the kind of thing that leveraging solr-benchmark for to confirm the minimal but real perf impact is acceptable would be worth doing? |
|
Measured it directly against the real
Going from 1 pass to 3 (the worst case -- shard requests hit the peek, the real suggestion pass, and the originalTerms echo) adds up to ~67us in the worst case measured. Against a typical query's millisecond-scale round-trip (index search, scoring, network), that's noise. I don't think the full solr-benchmark harness is needed to answer this specific question, but happy to add a proper benchmark class if you'd like this tracked over time rather than a one-off measurement. |
|
@epugh does this need a changelog entry, or can you add |
https://issues.apache.org/jira/browse/SOLR-18362
Removes the deprecated
org.apache.solr.spelling.Token-- a class whose own TODO called it out: "Refactor the spellchecker API to use TokenStreams properly, rather than this hack" (it worked by extending Lucene's internalPackedTokenAttributeImpl, never meant as a general-purpose value holder).SpellingQueryConverter/SuggestQueryConverter/SimpleQueryConverternow build a realTokenStream(new package-privateQueryWordsTokenStream, analyzing each parsed query word lazily) instead of materializing aCollection<Token>up frontSolrSpellCheckerimplementation (DirectSolrSpellChecker,AbstractLuceneSpellChecker,Suggester,WordBreakSolrSpellChecker) consumes viaincrementToken()and Lucene's own attribute interfaces (CharTermAttribute,OffsetAttribute,FlagsAttribute, etc.), not a pre-built collectionSpellCheckToken(not a LuceneAttributeImplsubclass) -- it's structurally forced bySolrSpellChecker#mergeSuggestions, which correlates suggestions from remote-shard responses by(text, offset)pairs deserialized off the wire, where there's noTokenStreamto read from at allSpellingOptions.tokens(aCollection<Token>) is nowtokenStreamSupplier(aSupplier<TokenStream>): aTokenStreamis single-use (reset/incrementToken-loop/end/close), so multiple consumers of the same query's terms (e.g.ConjunctionSolrSpellChecker's sub-checkers, orSpellCheckComponent's own emptiness-check + real use + originalTerms echo) each get a fresh instance rather than sharing/resetting oneQueryConverterorSolrSpellCheckerregistered viasolrconfig.xml:convert()'s return type,SpellingOptions's field, andSpellingResult's map key all changed118 tests, 0 failures (full
spelling/suggestpackage coverage plusSpellCheckComponentTestand the suggest-component tests).AI-assisted (Claude Sonnet 5)