Apache Lucene open-source search software
fix exc messages
Michael McCandlessacaa4eab0294
diff --git a/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java b/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.javaindex c83b3274620..7dc13d56d26 100644--- a/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java+++ b/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java@@ -76,31 +76,31 @@ final class TermVectorsConsumerPerField extends TermsHashConsumerPerField {doVectorPayloads |= field.fieldType().storeTermVectorPayloads();} else if (field.fieldType().storeTermVectorPayloads()) {// TODO: move this check somewhere else, and impl the other missing ones- throw new IllegalArgumentException("cannot index term vector payloads for field: " + field + " without term vector positions");+ throw new IllegalArgumentException("cannot index term vector payloads without term vector positions (field=\"" + field.name() + "\")");}} else {if (field.fieldType().storeTermVectorOffsets()) {- throw new IllegalArgumentException("cannot index term vector offsets when term vectors are not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vector offsets when term vectors are not indexed (field=\"" + field.name() + "\")");}if (field.fieldType().storeTermVectorPositions()) {- throw new IllegalArgumentException("cannot index term vector positions when term vectors are not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vector positions when term vectors are not indexed (field=\"" + field.name() + "\")");}if (field.fieldType().storeTermVectorPayloads()) {- throw new IllegalArgumentException("cannot index term vector payloads when term vectors are not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vector payloads when term vectors are not indexed (field=\"" + field.name() + "\")");}}} else {if (field.fieldType().storeTermVectors()) {- throw new IllegalArgumentException("cannot index term vectors when field is not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vectors when field is not indexed (field=\"" + field.name() + "\")");}if (field.fieldType().storeTermVectorOffsets()) {- throw new IllegalArgumentException("cannot index term vector offsets when field is not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vector offsets when field is not indexed (field=\"" + field.name() + "\")");}if (field.fieldType().storeTermVectorPositions()) {- throw new IllegalArgumentException("cannot index term vector positions when field is not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vector positions when field is not indexed (field=\"" + field.name() + "\")");}if (field.fieldType().storeTermVectorPayloads()) {- throw new IllegalArgumentException("cannot index term vector payloads when field is not indexed (field=\"" + field.name());+ throw new IllegalArgumentException("cannot index term vector payloads when field is not indexed (field=\"" + field.name() + "\")");}}}diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.javaindex 63018a181f1..9fe274ba4b9 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java@@ -331,4 +331,64 @@ public class TestTermVectorsReader extends LuceneTestCase {}reader.close();}++ public void testIllegalIndexableField() throws Exception {+ Directory dir = newDirectory();+ RandomIndexWriter w = new RandomIndexWriter(random(), dir);+ FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);+ ft.setStoreTermVectors(true);+ ft.setStoreTermVectorPayloads(true);+ Document doc = new Document();+ doc.add(new Field("field", "value", ft));+ try {+ w.addDocument(doc);+ fail("did not hit exception");+ } catch (IllegalArgumentException iae) {+ // Expected+ assertEquals("cannot index term vector payloads without term vector positions (field=\"field\")", iae.getMessage());+ }++ ft = new FieldType(TextField.TYPE_NOT_STORED);+ ft.setStoreTermVectors(false);+ ft.setStoreTermVectorOffsets(true);+ doc = new Document();+ doc.add(new Field("field", "value", ft));+ try {+ w.addDocument(doc);+ fail("did not hit exception");+ } catch (IllegalArgumentException iae) {+ // Expected+ assertEquals("cannot index term vector offsets when term vectors are not indexed (field=\"field\")", iae.getMessage());+ }++ ft = new FieldType(TextField.TYPE_NOT_STORED);+ ft.setStoreTermVectors(false);+ ft.setStoreTermVectorPositions(true);+ doc = new Document();+ doc.add(new Field("field", "value", ft));+ try {+ w.addDocument(doc);+ fail("did not hit exception");+ } catch (IllegalArgumentException iae) {+ // Expected+ assertEquals("cannot index term vector positions when term vectors are not indexed (field=\"field\")", iae.getMessage());+ }++ ft = new FieldType(TextField.TYPE_NOT_STORED);+ ft.setStoreTermVectors(false);+ ft.setStoreTermVectorPayloads(true);+ doc = new Document();+ doc.add(new Field("field", "value", ft));+ try {+ w.addDocument(doc);+ fail("did not hit exception");+ } catch (IllegalArgumentException iae) {+ // Expected+ assertEquals("cannot index term vector payloads when term vectors are not indexed (field=\"field\")", iae.getMessage());+ }++ w.close();++ dir.close();+ }}