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

Open
chenhh021 opened this issue Dec 11, 2022 · 1 comment · May be fixed by #781
Open

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

chenhh021 opened this issue Dec 11, 2022 · 1 comment · May be fixed by #781

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 chenhh021 linked a pull request Dec 12, 2022 that will close this issue
@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.

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.

1 participant