Fix multi-word search returning 0 results with JenaText#1932
Open
fvogel wants to merge 1 commit intoNatLibFi:mainfrom
Open
Fix multi-word search returning 0 results with JenaText#1932fvogel wants to merge 1 commit intoNatLibFi:mainfrom
fvogel wants to merge 1 commit intoNatLibFi:mainfrom
Conversation
Remove space from LUCENE_ESCAPE_CHARS and split multi-word queries into individual required Lucene terms using the '+' operator. Previously, spaces were escaped as '\ ', creating a single-token query like "Siamese\ cat*" that never matches any indexed term because StandardAnalyzer tokenizes labels into individual words. Now "Siamese cat*" becomes "+Siamese +cat*", requiring each word to match independently. Fixes NatLibFi#1930
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes #1930 — multi-word search queries (e.g. "Siamese cat", "Labrador retriever") return 0 results when using
sparqlDialect "JenaText".Root cause:
LUCENE_ESCAPE_CHARSincludes a space character, socreateTextQueryCondition()escapes spaces as\, producing a single-token query like"Siamese\ cat*". Since StandardAnalyzer tokenizes labels into individual words, no token ever contains a literal space and the query never matches.Fix:
LUCENE_ESCAPE_CHARS+(Lucene "required" operator)"Siamese cat*"becomes"+Siamese +cat*"— each word must match independentlyTest plan
Siamese*→ 1 resultSiamese cat*→ 1 result (was 0)Domestic cat*→ 1 result (was 0)Lab*→ 1 result (Labrador retriever)Tested against Skosmos 3.1 with Fuseki 5.4.0 (StandardAnalyzer, default config).