/** * initializes searcher with a document set */ public override void SetUp() { base.SetUp(); counter = Lucene.Net.Util.Counter.NewCounter(true); counterThread = new TimeLimitingCollector.TimerThread(counter); counterThread.Start(); string[] docText = { "docThatNeverMatchesSoWeCanRequireLastDocCollectedToBeGreaterThanZero", "one blah three", "one foo three multiOne", "one foobar three multiThree", "blueberry pancakes", "blueberry pie", "blueberry strudel", "blueberry pizza", }; directory = NewDirectory(); RandomIndexWriter iw = new RandomIndexWriter(Random(), directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy())); for (int i = 0; i < N_DOCS; i++) { Add(docText[i % docText.Length], iw); } reader = iw.Reader; iw.Dispose(); searcher = NewSearcher(reader); BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.Add(new TermQuery(new Term(FIELD_NAME, "one")), Occur.SHOULD); // start from 1, so that the 0th doc never matches for (int i = 1; i < docText.Length; i++) { string[] docTextParts = Regex.Split(docText[i], "\\s+"); foreach (string docTextPart in docTextParts) { // large query so that search will be longer booleanQuery.Add(new TermQuery(new Term(FIELD_NAME, docTextPart)), Occur.SHOULD); } } query = booleanQuery; // warm the searcher searcher.Search(query, null, 1000); }
/** * initializes searcher with a document set */ public override void SetUp() { base.SetUp(); counter = Lucene.Net.Util.Counter.NewCounter(true); counterThread = new TimeLimitingCollector.TimerThread(counter); counterThread.Start(); string[] docText = { "docThatNeverMatchesSoWeCanRequireLastDocCollectedToBeGreaterThanZero", "one blah three", "one foo three multiOne", "one foobar three multiThree", "blueberry pancakes", "blueberry pie", "blueberry strudel", "blueberry pizza", }; directory = NewDirectory(); RandomIndexWriter iw = new RandomIndexWriter(Random(), directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy())); for (int i = 0; i < N_DOCS; i++) { Add(docText[i % docText.Length], iw); } reader = iw.Reader; iw.Dispose(); searcher = NewSearcher(reader); BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.Add(new TermQuery(new Term(FIELD_NAME, "one")), BooleanClause.Occur.SHOULD); // start from 1, so that the 0th doc never matches for (int i = 1; i < docText.Length; i++) { string[] docTextParts = Regex.Split(docText[i], "\\s+"); foreach (string docTextPart in docTextParts) { // large query so that search will be longer booleanQuery.Add(new TermQuery(new Term(FIELD_NAME, docTextPart)), BooleanClause.Occur.SHOULD); } } query = booleanQuery; // warm the searcher searcher.Search(query, null, 1000); }