Index: lucene/CHANGES.txt
===================================================================
--- lucene/CHANGES.txt	(revision 1455785)
+++ lucene/CHANGES.txt	(working copy)
@@ -61,6 +61,10 @@
   subclasses with ctors taking AttributeFactory. 
   (Renaud Delbru, Uwe Schindler, Steve Rowe)
 
+* LUCENE-4816: Passing null as the BreakIterator to PostingsHighlighter
+  now highlights the entire content as a single Passage.  (Robert
+  Muir, Mike McCandless)
+
 Optimizations
 
 * LUCENE-4819: Added Sorted[Set]DocValues.termsEnum(), and optimized the
Index: lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java	(revision 1455785)
+++ lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java	(working copy)
@@ -406,4 +406,35 @@
     ir.close();
     dir.close();
   }
+
+  public void testHighlightAllText() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
+    iwc.setMergePolicy(newLogMergePolicy());
+    RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
+    
+    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
+    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
+    Field body = new Field("body", "", offsetsType);
+    Document doc = new Document();
+    doc.add(body);
+    
+    body.setStringValue("This is a test.  Just highlighting from postings. This is also a much sillier test.  Feel free to test test test test test test test.");
+    iw.addDocument(doc);
+    
+    IndexReader ir = iw.getReader();
+    iw.close();
+    
+    IndexSearcher searcher = newSearcher(ir);
+    PostingsHighlighter highlighter = new PostingsHighlighter(10000, null, new PassageScorer(), new PassageFormatter());
+    Query query = new TermQuery(new Term("body", "test"));
+    TopDocs topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);
+    assertEquals(1, topDocs.totalHits);
+    String snippets[] = highlighter.highlight("body", query, searcher, topDocs, 2);
+    assertEquals(1, snippets.length);
+    assertEquals("This is a <b>test</b>.  Just highlighting from postings. This is also a much sillier <b>test</b>.  Feel free to <b>test</b> <b>test</b> <b>test</b> <b>test</b> <b>test</b> <b>test</b> <b>test</b>.", snippets[0]);
+    
+    ir.close();
+    dir.close();
+  }
 }
Index: lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/PostingsHighlighter.java
===================================================================
--- lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/PostingsHighlighter.java	(revision 1455785)
+++ lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/PostingsHighlighter.java	(working copy)
@@ -118,7 +118,9 @@
   /**
    * Creates a new highlighter with custom parameters.
    * @param maxLength maximum content size to process.
-   * @param breakIterator used for finding passage boundaries.
+   * @param breakIterator used for finding passage
+   *        boundaries; pass null to highlight the entire
+   *        content as a single Passage.
    * @param scorer used for ranking passages.
    * @param formatter used for formatting passages into highlighted snippets.
    * @throws IllegalArgumentException if <code>maxLength</code> is negative or <code>Integer.MAX_VALUE</code>
@@ -129,7 +131,10 @@
       // our sentinel in the offsets queue uses this value to terminate.
       throw new IllegalArgumentException("maxLength must be < Integer.MAX_VALUE");
     }
-    if (breakIterator == null || scorer == null || formatter == null) {
+    if (breakIterator == null) {
+      breakIterator = new WholeBreakIterator();
+    }
+    if (scorer == null || formatter == null) {
       throw new NullPointerException();
     }
     this.maxLength = maxLength;
Index: lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/WholeBreakIterator.java
===================================================================
--- lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/WholeBreakIterator.java	(revision 0)
+++ lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/WholeBreakIterator.java	(working copy)
@@ -0,0 +1,110 @@
+package org.apache.lucene.search.postingshighlight;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.text.BreakIterator;
+import java.text.CharacterIterator;
+
+/** Just produces one single fragment for the entire
+ *  string. */
+final class WholeBreakIterator extends BreakIterator {
+  private CharacterIterator text;
+  private int len;
+  private int current;
+
+  @Override
+  public int current() {
+    return current;
+  }
+
+  @Override
+  public int first() {
+    return (current = 0);
+  }
+
+  @Override
+  public int following(int pos) {
+    if (pos < 0 || pos > len) {
+      throw new IllegalArgumentException("offset out of bounds");
+    } else if (pos == len) {
+      return DONE;
+    } else {
+      return last();
+    }
+  }
+
+  @Override
+  public CharacterIterator getText() {
+    return text;
+  }
+
+  @Override
+  public int last() {
+    return (current = len);
+  }
+
+  @Override
+  public int next() {
+    if (current == len) {
+      return DONE;
+    } else {
+      return last();
+    }
+  }
+
+  @Override
+  public int next(int n) {
+    if (n < 0) {
+      for (int i = 0; i < -n; i++) {
+        previous();
+      }
+    } else {
+      for (int i = 0; i < n; i++) {
+        next();
+      }
+    }
+    return current();
+  }
+
+  @Override
+  public int preceding(int pos) {
+    if (pos < 0 || pos > len) {
+      throw new IllegalArgumentException("offset out of bounds");
+    } else if (pos == 0) {
+      return DONE;
+    } else {
+      return first();
+    }
+  }
+
+  @Override
+  public int previous() {
+    if (current == 0) {
+      return DONE;
+    } else {
+      return first();
+    }
+  }
+
+  @Override
+  public void setText(CharacterIterator newText) {
+    len = newText.getEndIndex();
+    text = newText;
+    current = 0;
+  }
+}

Property changes on: lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/WholeBreakIterator.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
