You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/11/30 12:07:19 UTC
svn commit: r1642535 [18/19] - in /lucene/dev/branches/lucene6005/lucene:
analysis/common/src/java/org/apache/lucene/collation/
analysis/common/src/test/org/apache/lucene/analysis/core/
analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/...
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java Sun Nov 30 11:07:09 2014
@@ -42,9 +42,7 @@ import org.apache.lucene.analysis.tokena
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.TextField;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
@@ -313,15 +311,10 @@ public class FreeTextSuggester extends L
iwc.setRAMBufferSizeMB(ramBufferSizeMB);
IndexWriter writer = new IndexWriter(dir, iwc);
- FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
- // TODO: if only we had IndexOptions.TERMS_ONLY...
- ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
- ft.setOmitNorms(true);
- ft.freeze();
-
- Document doc = new Document();
- Field field = new Field("body", "", ft);
- doc.add(field);
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.disableHighlighting("body");
+ fieldTypes.disableNorms("body");
+ fieldTypes.setIndexOptions("body", IndexOptions.DOCS_AND_FREQS);
totTokens = 0;
IndexReader reader = null;
@@ -334,7 +327,8 @@ public class FreeTextSuggester extends L
if (surfaceForm == null) {
break;
}
- field.setStringValue(surfaceForm.utf8ToString());
+ Document doc = writer.newDocument();
+ doc.addLargeText("body", surfaceForm.utf8ToString());
writer.addDocument(doc);
count++;
}
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java Sun Nov 30 11:07:09 2014
@@ -20,7 +20,6 @@ package org.apache.lucene.search.spell;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -38,8 +37,8 @@ public class TestDirectSpellChecker exte
String[] termsToAdd = { "metanoia", "metanoian", "metanoiai", "metanoias", "metanoið" };
for (int i = 0; i < termsToAdd.length; i++) {
- Document doc = new Document();
- doc.add(newTextField("repentance", termsToAdd[i], Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("repentance", termsToAdd[i]);
writer.addDocument(doc);
}
@@ -67,8 +66,8 @@ public class TestDirectSpellChecker exte
new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
- Document doc = new Document();
- doc.add(newTextField("numbers", English.intToEnglish(i), Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", English.intToEnglish(i));
writer.addDocument(doc);
}
@@ -107,8 +106,8 @@ public class TestDirectSpellChecker exte
// add some more documents
for (int i = 1000; i < 1100; i++) {
- Document doc = new Document();
- doc.add(newTextField("numbers", English.intToEnglish(i), Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", English.intToEnglish(i));
writer.addDocument(doc);
}
@@ -131,14 +130,20 @@ public class TestDirectSpellChecker exte
RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
- Document doc = new Document();
- doc.add(newTextField("text", "foobar", Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("text", "foobar");
writer.addDocument(doc);
- doc.add(newTextField("text", "foobar", Field.Store.NO));
+
+ doc = writer.newDocument();
+ doc.addLargeText("text", "foobar");
writer.addDocument(doc);
- doc.add(newTextField("text", "foobaz", Field.Store.NO));
+
+ doc = writer.newDocument();
+ doc.addLargeText("text", "foobaz");
writer.addDocument(doc);
- doc.add(newTextField("text", "fobar", Field.Store.NO));
+
+ doc = writer.newDocument();
+ doc.addLargeText("text", "fobar");
writer.addDocument(doc);
IndexReader ir = writer.getReader();
@@ -199,8 +204,8 @@ public class TestDirectSpellChecker exte
new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
- Document doc = new Document();
- doc.add(newTextField("numbers", English.intToEnglish(i), Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", English.intToEnglish(i));
writer.addDocument(doc);
}
@@ -223,8 +228,8 @@ public class TestDirectSpellChecker exte
new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
- Document doc = new Document();
- doc.add(newTextField("numbers", English.intToEnglish(i), Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", English.intToEnglish(i));
writer.addDocument(doc);
}
@@ -248,8 +253,8 @@ public class TestDirectSpellChecker exte
new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
for (int i = 0; i < 20; i++) {
- Document doc = new Document();
- doc.add(newTextField("numbers", English.intToEnglish(i), Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", English.intToEnglish(i));
writer.addDocument(doc);
}
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java Sun Nov 30 11:07:09 2014
@@ -22,7 +22,6 @@ import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@@ -53,24 +52,24 @@ public class TestLuceneDictionary extend
Document doc;
- doc = new Document();
- doc.add(newTextField("aaa", "foo", Field.Store.YES));
+ doc = writer.newDocument();
+ doc.addLargeText("aaa", "foo");
writer.addDocument(doc);
- doc = new Document();
- doc.add(newTextField("aaa", "foo", Field.Store.YES));
+ doc = writer.newDocument();
+ doc.addLargeText("aaa", "foo");
writer.addDocument(doc);
- doc = new Document();
- doc.add(newTextField("contents", "Tom", Field.Store.YES));
+ doc = writer.newDocument();
+ doc.addLargeText("contents", "Tom");
writer.addDocument(doc);
- doc = new Document();
- doc.add(newTextField("contents", "Jerry", Field.Store.YES));
+ doc = writer.newDocument();
+ doc.addLargeText("contents", "Jerry");
writer.addDocument(doc);
- doc = new Document();
- doc.add(newTextField("zzz", "bar", Field.Store.YES));
+ doc = writer.newDocument();
+ doc.addLargeText("zzz", "bar");
writer.addDocument(doc);
writer.forceMerge(1);
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java Sun Nov 30 11:07:09 2014
@@ -29,7 +29,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@@ -58,28 +57,28 @@ public class TestSpellChecker extends Lu
IndexWriter writer = new IndexWriter(userindex, new IndexWriterConfig(new MockAnalyzer(random())));
for (int i = 0; i < 1000; i++) {
- Document doc = new Document();
- doc.add(newTextField("field1", English.intToEnglish(i), Field.Store.YES));
- doc.add(newTextField("field2", English.intToEnglish(i + 1), Field.Store.YES)); // + word thousand
- doc.add(newTextField("field3", "fvei" + (i % 2 == 0 ? " five" : ""), Field.Store.YES)); // + word thousand
+ Document doc = writer.newDocument();
+ doc.addLargeText("field1", English.intToEnglish(i));
+ doc.addLargeText("field2", English.intToEnglish(i + 1)); // + word thousand
+ doc.addLargeText("field3", "fvei" + (i % 2 == 0 ? " five" : "")); // + word thousand
writer.addDocument(doc);
}
{
- Document doc = new Document();
- doc.add(newTextField("field1", "eight", Field.Store.YES)); // "eight" in
+ Document doc = writer.newDocument();
+ doc.addLargeText("field1", "eight"); // "eight" in
// the index
// twice
writer.addDocument(doc);
}
{
- Document doc = new Document();
+ Document doc = writer.newDocument();
doc
- .add(newTextField("field1", "twenty-one twenty-one", Field.Store.YES)); // "twenty-one" in the index thrice
+ .addLargeText("field1", "twenty-one twenty-one"); // "twenty-one" in the index thrice
writer.addDocument(doc);
}
{
- Document doc = new Document();
- doc.add(newTextField("field1", "twenty", Field.Store.YES)); // "twenty"
+ Document doc = writer.newDocument();
+ doc.addLargeText("field1", "twenty"); // "twenty"
// in the
// index
// twice
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java Sun Nov 30 11:07:09 2014
@@ -26,7 +26,6 @@ import junit.framework.Assert;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
@@ -47,25 +46,25 @@ public class TestWordBreakSpellChecker e
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true));
for (int i = 900; i < 1112; i++) {
- Document doc = new Document();
+ Document doc = writer.newDocument();
String num = English.intToEnglish(i).replaceAll("[-]", " ").replaceAll("[,]", "");
- doc.add(newTextField("numbers", num, Field.Store.NO));
+ doc.addLargeText("numbers", num);
writer.addDocument(doc);
}
{
- Document doc = new Document();
- doc.add(newTextField("numbers", "thou hast sand betwixt thy toes", Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", "thou hast sand betwixt thy toes");
writer.addDocument(doc);
}
{
- Document doc = new Document();
- doc.add(newTextField("numbers", "hundredeight eightyeight yeight", Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", "hundredeight eightyeight yeight");
writer.addDocument(doc);
}
{
- Document doc = new Document();
- doc.add(newTextField("numbers", "tres y cinco", Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("numbers", "tres y cinco");
writer.addDocument(doc);
}
@@ -293,10 +292,9 @@ public class TestWordBreakSpellChecker e
broken[0] = orig.substring(0, breakAt);
broken[1] = orig.substring(breakAt);
breaks.add(broken);
- Document doc = new Document();
- doc.add(newTextField("random_break", broken[0] + " " + broken[1],
- Field.Store.NO));
- doc.add(newTextField("random_combine", orig, Field.Store.NO));
+ Document doc = writer.newDocument();
+ doc.addLargeText("random_break", broken[0] + " " + broken[1]);
+ doc.addLargeText("random_combine", orig);
writer.addDocument(doc);
}
writer.commit();
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java Sun Nov 30 11:07:09 2014
@@ -13,10 +13,7 @@ import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.document.TextField;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
@@ -54,18 +51,23 @@ public class DocumentDictionaryTest exte
static final String CONTEXT_FIELD_NAME = "c1";
/** Returns Pair(list of invalid document terms, Map of document term -> document) */
- private Map.Entry<List<String>, Map<String, Document>> generateIndexDocuments(int ndocs, boolean requiresPayload, boolean requiresContexts) {
+ private Map.Entry<List<String>, Map<String, Document>> generateIndexDocuments(RandomIndexWriter writer, int ndocs, boolean requiresPayload, boolean requiresContexts) {
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.setMultiValued(CONTEXT_FIELD_NAME);
+
Map<String, Document> docs = new HashMap<>();
List<String> invalidDocTerms = new ArrayList<>();
+ boolean useStoredFieldWeights = rarely();
for(int i = 0; i < ndocs ; i++) {
- Document doc = new Document();
+ Document doc = writer.newDocument();
boolean invalidDoc = false;
- Field field = null;
// usually have valid term field in document
+ String term;
if (usually()) {
- field = new TextField(FIELD_NAME, "field_" + i, Field.Store.YES);
- doc.add(field);
+ term = "field_" + i;
+ doc.addLargeText(FIELD_NAME, term);
} else {
+ term = "invalid_" + i;
invalidDoc = true;
}
@@ -73,8 +75,7 @@ public class DocumentDictionaryTest exte
if (requiresPayload || usually()) {
// usually have valid payload field in document
if (usually()) {
- Field payload = new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
- doc.add(payload);
+ doc.addStored(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
} else if (requiresPayload) {
invalidDoc = true;
}
@@ -83,7 +84,7 @@ public class DocumentDictionaryTest exte
if (requiresContexts || usually()) {
if (usually()) {
for (int j = 0; j < atLeast(2); j++) {
- doc.add(new StoredField(CONTEXT_FIELD_NAME, new BytesRef("context_" + i + "_"+ j)));
+ doc.addStored(CONTEXT_FIELD_NAME, new BytesRef("context_" + i + "_"+ j));
}
}
// we should allow entries without context
@@ -91,18 +92,15 @@ public class DocumentDictionaryTest exte
// usually have valid weight field in document
if (usually()) {
- Field weight = (rarely()) ?
- new StoredField(WEIGHT_FIELD_NAME, 100d + i) :
- new NumericDocValuesField(WEIGHT_FIELD_NAME, 100 + i);
- doc.add(weight);
+ if (useStoredFieldWeights) {
+ doc.addStoredDouble(WEIGHT_FIELD_NAME, 100d + i);
+ } else {
+ doc.addLong(WEIGHT_FIELD_NAME, 100 + i);
+ }
}
- String term = null;
if (invalidDoc) {
- term = (field!=null) ? field.stringValue() : "invalid_" + i;
invalidDocTerms.add(term);
- } else {
- term = field.stringValue();
}
docs.put(term, doc);
@@ -137,7 +135,7 @@ public class DocumentDictionaryTest exte
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(atLeast(1000), true, false);
+ Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(writer, atLeast(1000), true, false);
Map<String, Document> docs = res.getValue();
List<String> invalidDocTerms = res.getKey();
for(Document doc: docs.values()) {
@@ -151,7 +149,7 @@ public class DocumentDictionaryTest exte
BytesRef f;
while((f = inputIterator.next())!=null) {
Document doc = docs.remove(f.utf8ToString());
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
@@ -172,7 +170,7 @@ public class DocumentDictionaryTest exte
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(atLeast(1000), false, false);
+ Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(writer, atLeast(1000), false, false);
Map<String, Document> docs = res.getValue();
List<String> invalidDocTerms = res.getKey();
for(Document doc: docs.values()) {
@@ -186,7 +184,7 @@ public class DocumentDictionaryTest exte
BytesRef f;
while((f = inputIterator.next())!=null) {
Document doc = docs.remove(f.utf8ToString());
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
assertEquals(inputIterator.payload(), null);
@@ -208,7 +206,7 @@ public class DocumentDictionaryTest exte
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(atLeast(1000), true, true);
+ Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(writer, atLeast(1000), true, true);
Map<String, Document> docs = res.getValue();
List<String> invalidDocTerms = res.getKey();
for(Document doc: docs.values()) {
@@ -222,7 +220,7 @@ public class DocumentDictionaryTest exte
BytesRef f;
while((f = inputIterator.next())!=null) {
Document doc = docs.remove(f.utf8ToString());
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
@@ -249,7 +247,7 @@ public class DocumentDictionaryTest exte
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(atLeast(1000), false, false);
+ Map.Entry<List<String>, Map<String, Document>> res = generateIndexDocuments(writer, atLeast(1000), false, false);
Map<String, Document> docs = res.getValue();
List<String> invalidDocTerms = res.getKey();
Random rand = random();
@@ -257,7 +255,7 @@ public class DocumentDictionaryTest exte
for(Document doc : docs.values()) {
IndexableField f = doc.getField(FIELD_NAME);
if(rand.nextBoolean() && f != null && !invalidDocTerms.contains(f.stringValue())) {
- termsToDel.add(doc.get(FIELD_NAME));
+ termsToDel.add(doc.getString(FIELD_NAME));
}
writer.addDocument(doc);
}
@@ -285,7 +283,7 @@ public class DocumentDictionaryTest exte
BytesRef f;
while((f = inputIterator.next())!=null) {
Document doc = docs.remove(f.utf8ToString());
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
assertEquals(inputIterator.payload(), null);
@@ -331,38 +329,35 @@ public class DocumentDictionaryTest exte
private List<Suggestion> indexMultiValuedDocuments(int numDocs, RandomIndexWriter writer) throws IOException {
List<Suggestion> suggestionList = new ArrayList<>(numDocs);
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.setMultiValued(FIELD_NAME);
for(int i=0; i<numDocs; i++) {
- Document doc = new Document();
- Field field;
+ Document doc = writer.newDocument();
BytesRef payloadValue;
Set<BytesRef> contextValues = new HashSet<>();
long numericValue = -1; //-1 for missing weight
BytesRef term;
payloadValue = new BytesRef("payload_" + i);
- field = new StoredField(PAYLOAD_FIELD_NAME, payloadValue);
- doc.add(field);
+ doc.addStored(PAYLOAD_FIELD_NAME, payloadValue);
if (usually()) {
numericValue = 100 + i;
- field = new NumericDocValuesField(WEIGHT_FIELD_NAME, numericValue);
- doc.add(field);
+ doc.addLong(WEIGHT_FIELD_NAME, numericValue);
}
int numContexts = atLeast(1);
for (int j=0; j<numContexts; j++) {
BytesRef contextValue = new BytesRef("context_" + i + "_" + j);
- field = new StoredField(CONTEXT_FIELD_NAME, contextValue);
- doc.add(field);
+ doc.addStored(CONTEXT_FIELD_NAME, contextValue);
contextValues.add(contextValue);
}
int numSuggestions = atLeast(2);
for (int j=0; j<numSuggestions; j++) {
term = new BytesRef("field_" + i + "_" + j);
- field = new StoredField(FIELD_NAME, term);
- doc.add(field);
+ doc.addStored(FIELD_NAME, term);
Suggestion suggestionValue = new Suggestion();
suggestionValue.payload = payloadValue;
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java Sun Nov 30 11:07:09 2014
@@ -28,10 +28,7 @@ import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.document.TextField;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
@@ -57,27 +54,22 @@ public class DocumentValueSourceDictiona
static final String PAYLOAD_FIELD_NAME = "p1";
static final String CONTEXTS_FIELD_NAME = "c1";
- private Map<String, Document> generateIndexDocuments(int ndocs) {
+ private Map<String, Document> generateIndexDocuments(RandomIndexWriter writer, int ndocs) {
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.setMultiValued(CONTEXTS_FIELD_NAME);
Map<String, Document> docs = new HashMap<>();
for(int i = 0; i < ndocs ; i++) {
- Field field = new TextField(FIELD_NAME, "field_" + i, Field.Store.YES);
- Field payload = new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
- Field weight1 = new NumericDocValuesField(WEIGHT_FIELD_NAME_1, 10 + i);
- Field weight2 = new NumericDocValuesField(WEIGHT_FIELD_NAME_2, 20 + i);
- Field weight3 = new NumericDocValuesField(WEIGHT_FIELD_NAME_3, 30 + i);
- Field contexts = new StoredField(CONTEXTS_FIELD_NAME, new BytesRef("ctx_" + i + "_0"));
- Document doc = new Document();
- doc.add(field);
- doc.add(payload);
- doc.add(weight1);
- doc.add(weight2);
- doc.add(weight3);
- doc.add(contexts);
+ Document doc = writer.newDocument();
+ doc.addLargeText(FIELD_NAME, "field_" + i);
+ doc.addStored(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
+ doc.addInt(WEIGHT_FIELD_NAME_1, 10 + i);
+ doc.addInt(WEIGHT_FIELD_NAME_2, 20 + i);
+ doc.addInt(WEIGHT_FIELD_NAME_3, 30 + i);
+ doc.addStored(CONTEXTS_FIELD_NAME, new BytesRef("ctx_" + i + "_0"));
for(int j = 1; j < atLeast(3); j++) {
- contexts.setBytesValue(new BytesRef("ctx_" + i + "_" + j));
- doc.add(contexts);
+ doc.addStored(CONTEXTS_FIELD_NAME, new BytesRef("ctx_" + i + "_" + j));
}
- docs.put(field.stringValue(), doc);
+ docs.put("field_" + i, doc);
}
return docs;
}
@@ -109,7 +101,7 @@ public class DocumentValueSourceDictiona
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map<String, Document> docs = generateIndexDocuments(atLeast(100));
+ Map<String, Document> docs = generateIndexDocuments(writer, atLeast(100));
for(Document doc: docs.values()) {
writer.addDocument(doc);
}
@@ -126,7 +118,7 @@ public class DocumentValueSourceDictiona
long w1 = doc.getField(WEIGHT_FIELD_NAME_1).numericValue().longValue();
long w2 = doc.getField(WEIGHT_FIELD_NAME_2).numericValue().longValue();
long w3 = doc.getField(WEIGHT_FIELD_NAME_3).numericValue().longValue();
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
assertEquals(inputIterator.weight(), (w1 + w2 + w3));
assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
}
@@ -141,7 +133,7 @@ public class DocumentValueSourceDictiona
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map<String, Document> docs = generateIndexDocuments(atLeast(100));
+ Map<String, Document> docs = generateIndexDocuments(writer, atLeast(100));
for(Document doc: docs.values()) {
writer.addDocument(doc);
}
@@ -158,7 +150,7 @@ public class DocumentValueSourceDictiona
long w1 = doc.getField(WEIGHT_FIELD_NAME_1).numericValue().longValue();
long w2 = doc.getField(WEIGHT_FIELD_NAME_2).numericValue().longValue();
long w3 = doc.getField(WEIGHT_FIELD_NAME_3).numericValue().longValue();
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
assertEquals(inputIterator.weight(), (w1 + w2 + w3));
assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
Set<BytesRef> originalCtxs = new HashSet<>();
@@ -178,7 +170,7 @@ public class DocumentValueSourceDictiona
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map<String, Document> docs = generateIndexDocuments(atLeast(100));
+ Map<String, Document> docs = generateIndexDocuments(writer, atLeast(100));
for(Document doc: docs.values()) {
writer.addDocument(doc);
}
@@ -195,7 +187,7 @@ public class DocumentValueSourceDictiona
long w1 = doc.getField(WEIGHT_FIELD_NAME_1).numericValue().longValue();
long w2 = doc.getField(WEIGHT_FIELD_NAME_2).numericValue().longValue();
long w3 = doc.getField(WEIGHT_FIELD_NAME_3).numericValue().longValue();
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
assertEquals(inputIterator.weight(), (w1 + w2 + w3));
assertEquals(inputIterator.payload(), null);
}
@@ -210,12 +202,12 @@ public class DocumentValueSourceDictiona
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map<String, Document> docs = generateIndexDocuments(atLeast(100));
+ Map<String, Document> docs = generateIndexDocuments(writer, atLeast(100));
Random rand = random();
List<String> termsToDel = new ArrayList<>();
for(Document doc : docs.values()) {
if(rand.nextBoolean() && termsToDel.size() < docs.size()-1) {
- termsToDel.add(doc.get(FIELD_NAME));
+ termsToDel.add(doc.getString(FIELD_NAME));
}
writer.addDocument(doc);
}
@@ -248,7 +240,7 @@ public class DocumentValueSourceDictiona
Document doc = docs.remove(f.utf8ToString());
long w1 = doc.getField(WEIGHT_FIELD_NAME_1).numericValue().longValue();
long w2 = doc.getField(WEIGHT_FIELD_NAME_2).numericValue().longValue();
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
assertEquals(inputIterator.weight(), w2+w1);
assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
}
@@ -264,7 +256,7 @@ public class DocumentValueSourceDictiona
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
- Map<String, Document> docs = generateIndexDocuments(atLeast(100));
+ Map<String, Document> docs = generateIndexDocuments(writer, atLeast(100));
for(Document doc: docs.values()) {
writer.addDocument(doc);
}
@@ -277,7 +269,7 @@ public class DocumentValueSourceDictiona
BytesRef f;
while((f = inputIterator.next())!=null) {
Document doc = docs.remove(f.utf8ToString());
- assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+ assertTrue(f.equals(new BytesRef(doc.getString(FIELD_NAME))));
assertEquals(inputIterator.weight(), 10);
assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
}
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java Sun Nov 30 11:07:09 2014
@@ -47,16 +47,10 @@ import org.apache.lucene.analysis.TokenS
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.document.Document2;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.suggest.Input;
import org.apache.lucene.search.suggest.InputArrayIterator;
import org.apache.lucene.search.suggest.Lookup.LookupResult;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.AttributeFactory;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LineFileDocsText;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java Sun Nov 30 11:07:09 2014
@@ -38,7 +38,6 @@ import org.apache.lucene.analysis.MockTo
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.StopFilter;
import org.apache.lucene.analysis.util.CharArraySet;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.suggest.Input;
import org.apache.lucene.search.suggest.InputArrayIterator;
@@ -147,7 +146,7 @@ public class TestFreeTextSuggester exten
@Override
public BytesRef next() {
- Document2 doc;
+ Document doc;
try {
doc = lfd.nextDoc();
} catch (IOException ioe) {
Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java Sun Nov 30 11:07:09 2014
@@ -30,12 +30,8 @@ import java.util.*;
import java.util.concurrent.CountDownLatch;
import org.apache.lucene.analysis.tokenattributes.*;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.FieldTypes;
-import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
@@ -43,7 +39,6 @@ import org.apache.lucene.util.Attribute;
import org.apache.lucene.util.AttributeFactory;
import org.apache.lucene.util.AttributeImpl;
import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LineFileDocsText;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.Rethrow;
@@ -553,7 +548,7 @@ public abstract class BaseTokenStreamTes
private static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean useCharFilter, boolean simple, boolean offsetsAreCorrect, RandomIndexWriter iw) throws IOException {
StringReader bogus = new StringReader("");
- Document2 doc = null;
+ Document doc = null;
final LineFileDocsText docs = new LineFileDocsText(random);
if (iw != null) {
FieldTypes fieldTypes = iw.getFieldTypes();
@@ -686,7 +681,7 @@ public abstract class BaseTokenStreamTes
checkAnalysisConsistency(random, a, useCharFilter, text, offsetsAreCorrect, null);
}
- private static void checkAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text, boolean offsetsAreCorrect, Document2 doc) throws IOException {
+ private static void checkAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text, boolean offsetsAreCorrect, Document doc) throws IOException {
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": NOTE: BaseTokenStreamTestCase: get first token stream now text=" + text);
Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java Sun Nov 30 11:07:09 2014
@@ -23,11 +23,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@@ -62,7 +58,7 @@ public abstract class CollationTestBase
BytesRef secondEnd) throws Exception {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(analyzer));
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLargeText("content", "\u0633\u0627\u0628");
doc.addAtom("body", "body");
writer.addDocument(doc);
@@ -93,7 +89,7 @@ public abstract class CollationTestBase
BytesRef secondEnd) throws Exception {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(analyzer));
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
// Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
// orders the U+0698 character before the U+0633 character, so the single
@@ -121,7 +117,7 @@ public abstract class CollationTestBase
Directory farsiIndex = newDirectory();
IndexWriter writer = new IndexWriter(farsiIndex, new IndexWriterConfig(analyzer));
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLargeText("content", "\u0633\u0627\u0628");
doc.addAtom("body", "body");
writer.addDocument(doc);
@@ -156,7 +152,7 @@ public abstract class CollationTestBase
StringBuilder buff = new StringBuilder(10);
int n = result.length;
for (int i = 0 ; i < n ; ++i) {
- Document2 doc = searcher.doc(result[i].doc);
+ Document doc = searcher.doc(result[i].doc);
for (IndexableField f : doc.getFields("tracer")) {
buff.append(f.stringValue());
}
Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java Sun Nov 30 11:07:09 2014
@@ -34,6 +34,7 @@ import org.apache.lucene.util.BytesRef;
*/
public class LowSchemaField implements IndexableFieldType, IndexableField {
+ private final Analyzer analyzer;
private final String fieldName;
private final Object value;
private final boolean tokenized;
@@ -48,7 +49,8 @@ public class LowSchemaField implements I
private float boost = 1.0f;
private boolean omitNorms;
- public LowSchemaField(String fieldName, Object value, IndexOptions indexOptions, boolean tokenized) {
+ public LowSchemaField(Analyzer analyzer, String fieldName, Object value, IndexOptions indexOptions, boolean tokenized) {
+ this.analyzer = analyzer;
this.fieldName = fieldName;
this.value = value;
this.indexOptions = indexOptions;
@@ -135,7 +137,7 @@ public class LowSchemaField implements I
// nocommit need test trying to do index field with tokenized=false, and Reader value
@Override
- public TokenStream tokenStream(Analyzer analyzer, TokenStream reuse) throws IOException {
+ public TokenStream tokenStream(TokenStream reuse) throws IOException {
if (tokenStream != null) {
return tokenStream;
} else if (indexOptions != IndexOptions.NONE) {
Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java Sun Nov 30 11:07:09 2014
@@ -24,10 +24,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.StoredField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FilterDirectory;
import org.apache.lucene.store.FlushInfo;
@@ -183,15 +180,10 @@ public abstract class BaseCompoundFormat
}
// riw should sometimes create docvalues fields, etc
RandomIndexWriter riw = new RandomIndexWriter(random(), dir);
- Document doc = new Document();
- // these fields should sometimes get term vectors, etc
- Field idField = newStringField("id", "", Field.Store.NO);
- Field bodyField = newTextField("body", "", Field.Store.NO);
- doc.add(idField);
- doc.add(bodyField);
for (int i = 0; i < 100; i++) {
- idField.setStringValue(Integer.toString(i));
- bodyField.setStringValue(TestUtil.randomUnicodeString(random()));
+ Document doc = riw.newDocument();
+ doc.addAtom("id", Integer.toString(i));
+ doc.addLargeText("body", TestUtil.randomUnicodeString(random()));
riw.addDocument(doc);
if (random().nextInt(7) == 0) {
riw.commit();
@@ -735,7 +727,7 @@ public abstract class BaseCompoundFormat
}
@Override
- protected void addRandomFields(Document2 doc) {
+ protected void addRandomFields(Document doc) {
doc.addStored("foobar", TestUtil.randomSimpleString(random()));
}
Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java Sun Nov 30 11:07:09 2014
@@ -22,10 +22,8 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.FieldTypes;
-import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.TestUtil;
@@ -63,14 +61,14 @@ public abstract class BaseCompressingDoc
} else {
value = RandomPicks.randomFrom(random(), values);
}
- final Document2 doc = iwriter.newDocument();
+ final Document doc = iwriter.newDocument();
doc.addLong("dv", value);
iwriter.addDocument(doc);
}
iwriter.forceMerge(1);
final long size1 = dirSize(dir);
for (int i = 0; i < 20; ++i) {
- final Document2 doc = iwriter.newDocument();
+ final Document doc = iwriter.newDocument();
doc.addLong("dv", RandomPicks.randomFrom(random(), values));
iwriter.addDocument(doc);
}
@@ -92,14 +90,14 @@ public abstract class BaseCompressingDoc
final long day = 1000L * 60 * 60 * 24;
for (int i = 0; i < 300; ++i) {
- final Document2 doc = iwriter.newDocument();
+ final Document doc = iwriter.newDocument();
doc.addLong("dv", base + random().nextInt(1000) * day);
iwriter.addDocument(doc);
}
iwriter.forceMerge(1);
final long size1 = dirSize(dir);
for (int i = 0; i < 50; ++i) {
- final Document2 doc = iwriter.newDocument();
+ final Document doc = iwriter.newDocument();
doc.addLong("dv", base + random().nextInt(1000) * day);
iwriter.addDocument(doc);
}
@@ -118,13 +116,13 @@ public abstract class BaseCompressingDoc
fieldTypes.disableStored("dv");
for (int i = 0; i < 20000; ++i) {
- final Document2 doc = iwriter.newDocument();
+ final Document doc = iwriter.newDocument();
doc.addLong("dv", i & 1023);
iwriter.addDocument(doc);
}
iwriter.forceMerge(1);
final long size1 = dirSize(dir);
- final Document2 doc = iwriter.newDocument();
+ final Document doc = iwriter.newDocument();
doc.addLong("dv", Long.MAX_VALUE);
iwriter.addDocument(doc);
iwriter.forceMerge(1);
Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java Sun Nov 30 11:07:09 2014
@@ -33,19 +33,8 @@ import java.util.concurrent.CountDownLat
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.document.BinaryDocValuesField;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldTypes;
-import org.apache.lucene.document.FloatDocValuesField;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.SortedDocValuesField;
-import org.apache.lucene.document.SortedNumericDocValuesField;
-import org.apache.lucene.document.SortedSetDocValuesField;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.document.TextField;
import org.apache.lucene.index.TermsEnum.SeekStatus;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
@@ -74,7 +63,7 @@ import static org.apache.lucene.index.So
public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTestCase {
@Override
- protected void addRandomFields(Document2 doc) {
+ protected void addRandomFields(Document doc) {
FieldTypes fieldTypes = doc.getFieldTypes();
fieldTypes.disableExistsFilters();
for(String fieldName : new String[] {"ndv", "bdv", "sdv", "ssdv", "sndv"}) {
@@ -105,7 +94,7 @@ public abstract class BaseDocValuesForma
public void testOneNumber() throws IOException {
Directory directory = newDirectory();
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -123,7 +112,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
@@ -137,7 +126,7 @@ public abstract class BaseDocValuesForma
public void testOneFloat() throws IOException {
Directory directory = newDirectory();
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -155,7 +144,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
@@ -169,7 +158,7 @@ public abstract class BaseDocValuesForma
public void testTwoNumbers() throws IOException {
Directory directory = newDirectory();
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -188,7 +177,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv1");
@@ -207,7 +196,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv1");
fieldTypes.disableSorting("dv2");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -226,7 +215,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv1");
@@ -246,7 +235,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv2");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -265,7 +254,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv1");
@@ -284,7 +273,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv3");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -304,7 +293,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv1");
@@ -328,7 +317,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv1");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -349,7 +338,7 @@ public abstract class BaseDocValuesForma
BytesRef scratch = new BytesRef();
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv2");
@@ -374,7 +363,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addInt("dv", 1);
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -401,7 +390,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
doc.addInt("dv", -10);
iwriter.addDocument(doc);
@@ -418,7 +407,7 @@ public abstract class BaseDocValuesForma
assert ireader.leaves().size() == 1;
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
for(int i=0;i<2;i++) {
- Document2 doc2 = ireader.leaves().get(0).reader().document(i);
+ Document doc2 = ireader.leaves().get(0).reader().document(i);
long expected;
if (doc2.getString("id").equals("0")) {
expected = -10;
@@ -439,7 +428,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addLong("dv", Long.MIN_VALUE);
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -466,7 +455,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addLong("dv", -8841491950446638677L);
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -494,7 +483,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -512,7 +501,7 @@ public abstract class BaseDocValuesForma
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv");
@@ -534,7 +523,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
doc.addBinary("dv", new BytesRef("hello world 1"));
iwriter.addDocument(doc);
@@ -552,7 +541,7 @@ public abstract class BaseDocValuesForma
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv");
BytesRef scratch = new BytesRef();
for(int i=0;i<2;i++) {
- Document2 doc2 = ireader.leaves().get(0).reader().document(i);
+ Document doc2 = ireader.leaves().get(0).reader().document(i);
String expected;
if (doc2.getString("id").equals("0")) {
expected = "hello world 1";
@@ -576,7 +565,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -603,7 +592,7 @@ public abstract class BaseDocValuesForma
Directory directory = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
String text = "This is the text to be indexed. " + longTerm;
doc.addLargeText("fieldname", text);
@@ -622,7 +611,7 @@ public abstract class BaseDocValuesForma
BytesRef scratch = new BytesRef();
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.getString("fieldname"));
assert ireader.leaves().size() == 1;
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv");
@@ -641,7 +630,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef("hello world 1"));
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -671,7 +660,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef("hello world 1"));
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -707,7 +696,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
doc.addBinary("dv", new BytesRef("hello world 1"));
iwriter.addDocument(doc);
@@ -729,7 +718,7 @@ public abstract class BaseDocValuesForma
scratch = dv.lookupOrd(1);
assertEquals(new BytesRef("hello world 2"), scratch);
for(int i=0;i<2;i++) {
- Document2 doc2 = ireader.leaves().get(0).reader().document(i);
+ Document doc2 = ireader.leaves().get(0).reader().document(i);
String expected;
if (doc2.getString("id").equals("0")) {
expected = "hello world 1";
@@ -751,7 +740,7 @@ public abstract class BaseDocValuesForma
iwconfig.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, iwconfig);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -790,7 +779,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef("hello\nworld\r1"));
iwriter.addDocument(doc);
iwriter.close();
@@ -813,7 +802,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef("hello world 2"));
iwriter.addDocument(doc);
// 2nd doc missing the DV field
@@ -842,7 +831,7 @@ public abstract class BaseDocValuesForma
iwconfig.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, iwconfig);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
iwriter.addDocument(doc);
@@ -915,7 +904,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef(""));
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -947,7 +936,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef(""));
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -978,7 +967,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
byte bytes[] = new byte[32766];
BytesRef b = new BytesRef(bytes);
random().nextBytes(bytes);
@@ -1004,7 +993,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
byte bytes[] = new byte[32766];
BytesRef b = new BytesRef(bytes);
random().nextBytes(bytes);
@@ -1031,7 +1020,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.disableSorting("dv");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef("boo!"));
iwriter.addDocument(doc);
iwriter.close();
@@ -1056,7 +1045,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(analyzer);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("dv", new BytesRef("boo!"));
iwriter.addDocument(doc);
iwriter.close();
@@ -1084,7 +1073,7 @@ public abstract class BaseDocValuesForma
conf.setMergePolicy(newLogMergePolicy());
IndexWriter writer = new IndexWriter(dir, conf);
for (int i = 0; i < 5; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addInt("docId", i);
doc.addLargeText("text", "" + i);
writer.addDocument(doc);
@@ -1132,7 +1121,7 @@ public abstract class BaseDocValuesForma
Map<String, String> docToString = new HashMap<>();
int maxLength = TestUtil.nextInt(random(), 1, 50);
for (int i = 0; i < numDocs; i++) {
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
doc.addLargeText("id", "" + i);
String string = TestUtil.randomRealisticUnicodeString(random(), 1, maxLength);
BytesRef br = new BytesRef(string);
@@ -1146,7 +1135,7 @@ public abstract class BaseDocValuesForma
}
int numDocsNoValue = atLeast(10);
for (int i = 0; i < numDocsNoValue; i++) {
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
doc.addLargeText("id", "noValue");
w.addDocument(doc);
}
@@ -1163,7 +1152,7 @@ public abstract class BaseDocValuesForma
w.forceMerge(1);
}
for (int i = 0; i < numDocs; i++) {
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
String id = "" + i + numDocs;
doc.addLargeText("id", id);
String string = TestUtil.randomRealisticUnicodeString(random(), 1, maxLength);
@@ -1227,7 +1216,7 @@ public abstract class BaseDocValuesForma
// for numbers of values <= 256, all storage layouts are tested
assert numDocs > 256;
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id", Integer.toString(i));
long value = longs.next();
doc.addAtom("stored", Long.toString(value));
@@ -1279,7 +1268,7 @@ public abstract class BaseDocValuesForma
// for numbers of values <= 256, all storage layouts are tested
assert numDocs > 256;
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id", Integer.toString(i));
int valueCount = (int) counts.next();
@@ -1376,7 +1365,7 @@ public abstract class BaseDocValuesForma
// index some docs
int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id", Integer.toString(i));
final int length;
if (minLength == maxLength) {
@@ -1453,7 +1442,7 @@ public abstract class BaseDocValuesForma
// index some docs
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id", Integer.toString(i));
final int length;
if (minLength == maxLength) {
@@ -1530,7 +1519,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
iwriter.addDocument(doc);
@@ -1558,7 +1547,7 @@ public abstract class BaseDocValuesForma
fieldTypes.setMultiValued("field");
fieldTypes.setMultiValued("field2");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
doc.addBinary("field2", new BytesRef("world"));
iwriter.addDocument(doc);
@@ -1598,7 +1587,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
iwriter.addDocument(doc);
iwriter.commit();
@@ -1640,7 +1629,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
doc.addBinary("field", new BytesRef("world"));
iwriter.addDocument(doc);
@@ -1672,7 +1661,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("world"));
doc.addBinary("field", new BytesRef("hello"));
iwriter.addDocument(doc);
@@ -1707,7 +1696,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
doc.addBinary("field", new BytesRef("world"));
iwriter.addDocument(doc);
@@ -1758,7 +1747,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
iwriter.addDocument(doc);
@@ -1792,7 +1781,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
iwriter.addDocument(doc);
iwriter.commit();
@@ -1828,7 +1817,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -1863,7 +1852,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
iwriter.addDocument(doc);
iwriter.commit();
@@ -1899,7 +1888,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -1930,7 +1919,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addBinary("field", new BytesRef("hello"));
doc.addBinary("field", new BytesRef("world"));
doc.addBinary("field", new BytesRef("beer"));
@@ -1997,7 +1986,7 @@ public abstract class BaseDocValuesForma
// index some docs
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id", Integer.toString(i));
final int length;
if (minLength == maxLength) {
@@ -2222,7 +2211,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(null);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iw = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addAtom("id", "0");
doc.addLong("dv1", 0);
iw.addDocument(doc);
@@ -2251,7 +2240,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(null);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iw = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addAtom("id", "0");
doc.addLong("dv1", 0);
iw.addDocument(doc);
@@ -2281,7 +2270,7 @@ public abstract class BaseDocValuesForma
IndexWriterConfig conf = newIndexWriterConfig(null);
conf.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iw = new RandomIndexWriter(random(), directory, conf);
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addAtom("id", "0");
doc.addLong("dv1", 0);
iw.addDocument(doc);
@@ -2319,7 +2308,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iw = new RandomIndexWriter(random(), directory, conf);
FieldTypes fieldTypes = iw.getFieldTypes();
fieldTypes.disableSorting("dv1");
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addAtom("id", "0");
doc.addBinary("dv1", new BytesRef());
iw.addDocument(doc);
@@ -2352,7 +2341,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iw = new RandomIndexWriter(random(), directory, conf);
FieldTypes fieldTypes = iw.getFieldTypes();
fieldTypes.disableSorting("dv1");
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addAtom("id", "0");
doc.addBinary("dv1", new BytesRef());
iw.addDocument(doc);
@@ -2386,7 +2375,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter iw = new RandomIndexWriter(random(), directory, conf);
FieldTypes fieldTypes = iw.getFieldTypes();
fieldTypes.disableSorting("dv1");
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addAtom("id", "0");
doc.addBinary("dv1", new BytesRef());
iw.addDocument(doc);
@@ -2430,7 +2419,7 @@ public abstract class BaseDocValuesForma
// index some docs
int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id",Integer.toString(i));
int length = TestUtil.nextInt(random(), 0, 8);
byte buffer[] = new byte[length];
@@ -2517,7 +2506,7 @@ public abstract class BaseDocValuesForma
// index some docs
int numDocs = TestUtil.nextInt(random(), 1025, 2047);
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addAtom("id", Integer.toString(i));
int length = TestUtil.nextInt(random(), 0, 8);
byte buffer[] = new byte[length];
@@ -2692,7 +2681,7 @@ public abstract class BaseDocValuesForma
int numDocs = TestUtil.nextInt(random(), 2025, 2047);
for (int i = 0; i < numDocs; i++) {
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
for (int j = 0; j < numSortedSets; j++) {
doc.addBinary("ss" + j, new BytesRef(TestUtil.randomSimpleString(random())));
@@ -2763,11 +2752,11 @@ public abstract class BaseDocValuesForma
bytes.bytes = new byte[1<<i];
bytes.length = 1<<i;
for(int j=0;j<4;j++) {
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
doc.addBinary("field", bytes);
w.addDocument(doc);
}
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
doc.addStored("id", "5");
doc.addBinary("field", new BytesRef());
w.addDocument(doc);
@@ -2791,7 +2780,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.setMultiValued("dv");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("dv", 5);
writer.addDocument(doc);
writer.close();
@@ -2814,7 +2803,7 @@ public abstract class BaseDocValuesForma
IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(null));
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.setMultiValued("dv");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("dv", 5);
writer.addDocument(doc);
writer.addDocument(writer.newDocument());
@@ -2846,7 +2835,7 @@ public abstract class BaseDocValuesForma
iwconfig.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, iwconfig);
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
iwriter.addDocument(doc);
doc = iwriter.newDocument();
@@ -2873,7 +2862,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.setMultiValued("dv");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("dv", 11);
doc.addLong("dv", -5);
writer.addDocument(doc);
@@ -2898,7 +2887,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.setMultiValued("dv");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("dv", 11);
doc.addLong("dv", 11);
writer.addDocument(doc);
@@ -2923,7 +2912,7 @@ public abstract class BaseDocValuesForma
IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(null));
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.setMultiValued("dv");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("dv", 11);
doc.addLong("dv", -5);
writer.addDocument(doc);
@@ -2958,7 +2947,7 @@ public abstract class BaseDocValuesForma
IndexWriter writer = new IndexWriter(directory, iwc);
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.setMultiValued("dv");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("dv", 11);
writer.addDocument(doc);
writer.commit();
@@ -2993,7 +2982,7 @@ public abstract class BaseDocValuesForma
FieldTypes fieldTypes = iwriter.getFieldTypes();
fieldTypes.setMultiValued("field");
- Document2 doc = iwriter.newDocument();
+ Document doc = iwriter.newDocument();
doc.addAtom("id", "0");
iwriter.addDocument(doc);
doc = iwriter.newDocument();