Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonGramsFilterFactory doesn't respect ignoreCase=true when default stopwords are used #780

Closed
chenhh021 opened this issue Dec 11, 2022 · 1 comment · Fixed by #781
Closed
Assignees

Comments

@chenhh021
Copy link
Contributor

See Lucene-10008. It's also valid for lucene.

CommonGramsFilterFactory's use of the "words" and "ignoreCase" config options is inconsistent with how StopFilterFactory uses them - leading to "ignoreCase=true" not being respected unless "words" is specified.

Reproduce:

[Test]
        public void testIgnoreCase()
        {
            IResourceLoader loader = new ClasspathResourceLoader(typeof(TestAnalyzers));
            CommonGramsFilterFactory factory =
                (CommonGramsFilterFactory)
                TokenFilterFactory("CommonGrams", TEST_VERSION_CURRENT, loader, "ignoreCase", "true");
            CharArraySet words = factory.CommonWords;
            assertTrue("words is null and it shouldn't be", words != null);
            assertTrue(words.contains("the")); //passes
            assertTrue(words.contains("The")); //fails
            Tokenizer tokenizer = new MockTokenizer(new StringReader("testing the factory"),MockTokenizer.WHITESPACE, false);
            TokenStream stream = factory.Create(tokenizer);
            AssertTokenStreamContents(
                stream, new String[] {"testing", "testing_The", "The", "The_factory", "factory"});
        }

Working for a PR now.

@chenhh021
Copy link
Contributor Author

PR created. It doesn't port the whole Lucene patch where a new base class was created, but applies minimum change solve the problem.

@paulirwin paulirwin added this to the 4.8.0-beta00018 milestone Oct 28, 2024
@paulirwin paulirwin self-assigned this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants