lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1510617 - in /lucene/dev/trunk/lucene/core/src: java/org/apache/lucene/index/TermVectorsConsumerPerField.java test/org/apache/lucene/index/TestTermVectorsReader.java
Date Mon, 05 Aug 2013 17:35:04 GMT
Author: mikemccand
Date: Mon Aug  5 17:35:04 2013
New Revision: 1510617

URL: http://svn.apache.org/r1510617
Log:
fix exc messages

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java?rev=1510617&r1=1510616&r2=1510617&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
Mon Aug  5 17:35:04 2013
@@ -76,31 +76,31 @@ final class TermVectorsConsumerPerField 
             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() + "\")");
         }
       }
     }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=1510617&r1=1510616&r2=1510617&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
Mon Aug  5 17:35:04 2013
@@ -331,4 +331,64 @@ public class TestTermVectorsReader exten
     }
     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();
+  }
 }



Mime
View raw message