[TEST] Fix TestNorms to ensure that max token lenght is at least 3 to have predictable norms

This commit is contained in:
Simon Willnauer 2018-05-09 10:04:18 +02:00
parent 1705e4f291
commit 6262b7757b
1 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,8 @@ public class TestNorms extends LuceneTestCase {
public void buildIndex(Directory dir) throws IOException { public void buildIndex(Directory dir) throws IOException {
Random random = random(); Random random = random();
MockAnalyzer analyzer = new MockAnalyzer(random()); MockAnalyzer analyzer = new MockAnalyzer(random());
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH)); // we need at least 3 for maxTokenLength otherwise norms are messed up
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 3, IndexWriter.MAX_TERM_LENGTH));
IndexWriterConfig config = newIndexWriterConfig(analyzer); IndexWriterConfig config = newIndexWriterConfig(analyzer);
Similarity provider = new MySimProvider(); Similarity provider = new MySimProvider();
config.setSimilarity(provider); config.setSimilarity(provider);