diff --git a/src/java/org/apache/lucene/search/PhraseQuery.java b/src/java/org/apache/lucene/search/PhraseQuery.java index dc9bed4829e..efcca47e2b2 100644 --- a/src/java/org/apache/lucene/search/PhraseQuery.java +++ b/src/java/org/apache/lucene/search/PhraseQuery.java @@ -256,7 +256,7 @@ public class PhraseQuery extends Query { /** Prints a user-readable version of this query. */ public String toString(String f) { StringBuffer buffer = new StringBuffer(); - if (!field.equals(f)) { + if (field != null && !field.equals(f)) { buffer.append(field); buffer.append(":"); } diff --git a/src/test/org/apache/lucene/search/TestPhraseQuery.java b/src/test/org/apache/lucene/search/TestPhraseQuery.java index 21714c29c58..e5ab3d8cae0 100644 --- a/src/test/org/apache/lucene/search/TestPhraseQuery.java +++ b/src/test/org/apache/lucene/search/TestPhraseQuery.java @@ -544,5 +544,13 @@ public class TestPhraseQuery extends LuceneTestCase { //assertTrue("reversed scores higher in palindrome",score1+SCORE_COMP_THRESH