mirror of https://github.com/apache/lucene.git
LUCENE-6866: limit max token length
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1711531 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ae779d8115
commit
d1a198a1f7
|
@ -17,18 +17,12 @@ package org.apache.lucene.index;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.lucene.util.IOUtils;
|
|
||||||
import org.apache.lucene.util.LineFileDocs;
|
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
|
||||||
import org.apache.lucene.store.Directory;
|
|
||||||
import org.apache.lucene.store.LockObtainFailedException;
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
|
||||||
import org.apache.lucene.analysis.CannedTokenStream;
|
import org.apache.lucene.analysis.CannedTokenStream;
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.analysis.Token;
|
import org.apache.lucene.analysis.Token;
|
||||||
|
@ -36,6 +30,12 @@ import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.FieldType;
|
import org.apache.lucene.document.FieldType;
|
||||||
import org.apache.lucene.document.TextField;
|
import org.apache.lucene.document.TextField;
|
||||||
|
import org.apache.lucene.store.Directory;
|
||||||
|
import org.apache.lucene.store.LockObtainFailedException;
|
||||||
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
import org.apache.lucene.util.LineFileDocs;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
public class TestCheckIndex extends LuceneTestCase {
|
public class TestCheckIndex extends LuceneTestCase {
|
||||||
|
|
||||||
|
@ -126,7 +126,8 @@ public class TestCheckIndex extends LuceneTestCase {
|
||||||
public void testChecksumsOnly() throws IOException {
|
public void testChecksumsOnly() throws IOException {
|
||||||
LineFileDocs lf = new LineFileDocs(random());
|
LineFileDocs lf = new LineFileDocs(random());
|
||||||
Directory dir = newDirectory();
|
Directory dir = newDirectory();
|
||||||
Analyzer analyzer = new MockAnalyzer(random());
|
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||||
|
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
||||||
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(analyzer));
|
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(analyzer));
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
iw.addDocument(lf.nextDoc());
|
iw.addDocument(lf.nextDoc());
|
||||||
|
@ -150,7 +151,8 @@ public class TestCheckIndex extends LuceneTestCase {
|
||||||
public void testChecksumsOnlyVerbose() throws IOException {
|
public void testChecksumsOnlyVerbose() throws IOException {
|
||||||
LineFileDocs lf = new LineFileDocs(random());
|
LineFileDocs lf = new LineFileDocs(random());
|
||||||
Directory dir = newDirectory();
|
Directory dir = newDirectory();
|
||||||
Analyzer analyzer = new MockAnalyzer(random());
|
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||||
|
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
||||||
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(analyzer));
|
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(analyzer));
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
iw.addDocument(lf.nextDoc());
|
iw.addDocument(lf.nextDoc());
|
||||||
|
|
Loading…
Reference in New Issue