question: public void testWickedLongTerm ( ) throws IOException { Directory dir = newDirectory ( ) ; RandomIndexWriter w = new RandomIndexWriter ( random ( ) , dir , new StringSplitAnalyzer ( ) ) ; char [ ] chars = new char [ DocumentsWriterPerThread . MAX_TERM_LENGTH_UTF8 ] ; Arrays . fill ( chars , 'x' ) ; Document hugeDoc = new Document ( ) ; final String bigTerm = new String ( chars ) ; String contents = "abc xyz x" + bigTerm + " another term" ; hugeDoc . add ( new TextField ( "content" , contents , Field . Store . NO ) ) ; expectThrows ( IllegalArgumentException . class , null ) ; Document doc = new Document ( ) ; doc . add ( new TextField ( "content" , "abc bbb ccc" , Field . Store . NO ) ) ; w . addDocument ( doc ) ; w . forceMerge ( 1 ) ; IndexReader reader = w . getReader ( ) ; w . close ( ) ; assertEquals ( 1 , reader . docFreq ( new Term ( "content" , "abc" ) ) ) ; assertEquals ( 1 , reader . docFreq ( new Term ( "content" , "bbb" ) ) ) ; assertEquals ( 0 , reader . docFreq ( new Term ( "content" , "term" ) ) ) ; assertEquals ( "document with wicked long term is in the index!" , 1 , reader . numDocs ( ) ) ; reader . close ( ) ; dir . close ( ) ; dir = newDirectory ( ) ; doc = new Document ( ) ; FieldType customType = new FieldType ( TextField . TYPE_NOT_STORED ) ; customType . setTokenized ( false ) ; Field contentField = new Field ( "content" , "" , customType ) ; doc . add ( contentField ) ; IndexWriterConfig iwc = newIndexWriterConfig ( ) ; iwc . setCodec ( TestUtil . getDefaultCodec ( ) ) ; RandomIndexWriter w2 = new RandomIndexWriter ( random ( ) , dir , iwc ) ; contentField . setStringValue ( "other" ) ; w2 . addDocument ( doc ) ; contentField . setStringValue ( "term" ) ; w2 . addDocument ( doc ) ; contentField . setStringValue ( bigTerm ) ; w2 . addDocument ( doc ) ; contentField . setStringValue ( "zzz" ) ; w2 . addDocument ( doc ) ; reader = w2 . getReader ( ) ; w2 . close ( ) ; assertEquals ( 1 , reader . docFreq ( new Term ( "content" , bigTerm ) ) ) ; reader . close ( ) ; dir . close ( ) ; }
target:  Make sure we skip wicked long terms.