public virtual void TestException() { try { BooleanQuery.SetMaxClauseCount(0); Assert.Fail(); } catch (System.ArgumentException e) { // okay } }
static TestNumericRangeQuery64() { { try { // set the theoretical maximum term count for 8bit (see docs for the number) BooleanQuery.SetMaxClauseCount(7 * 255 * 2 + 255); directory = new RAMDirectory(); IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, MaxFieldLength.UNLIMITED); NumericField field8 = new NumericField("field8", 8, Field.Store.YES, true), field6 = new NumericField("field6", 6, Field.Store.YES, true), field4 = new NumericField("field4", 4, Field.Store.YES, true), field2 = new NumericField("field2", 2, Field.Store.YES, true), fieldNoTrie = new NumericField("field" + System.Int32.MaxValue, System.Int32.MaxValue, Field.Store.YES, true), ascfield8 = new NumericField("ascfield8", 8, Field.Store.NO, true), ascfield6 = new NumericField("ascfield6", 6, Field.Store.NO, true), ascfield4 = new NumericField("ascfield4", 4, Field.Store.NO, true), ascfield2 = new NumericField("ascfield2", 2, Field.Store.NO, true); Document doc = new Document(); // add fields, that have a distance to test general functionality doc.Add(field8); doc.Add(field6); doc.Add(field4); doc.Add(field2); doc.Add(fieldNoTrie); // add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive doc.Add(ascfield8); doc.Add(ascfield6); doc.Add(ascfield4); doc.Add(ascfield2); // Add a series of noDocs docs with increasing long values, by updating the fields for (int l = 0; l < noDocs; l++) { long val = distance * l + startOffset; field8.SetLongValue(val); field6.SetLongValue(val); field4.SetLongValue(val); field2.SetLongValue(val); fieldNoTrie.SetLongValue(val); val = l - (noDocs / 2); ascfield8.SetLongValue(val); ascfield6.SetLongValue(val); ascfield4.SetLongValue(val); ascfield2.SetLongValue(val); writer.AddDocument(doc); } writer.Optimize(); writer.Close(); searcher = new IndexSearcher(directory, true); } catch (System.Exception e) { throw new System.SystemException("", e); } } }