Index: src/java/org/apache/lucene/search/IndexSearcher.java
===================================================================
--- src/java/org/apache/lucene/search/IndexSearcher.java (revision 514225)
+++ src/java/org/apache/lucene/search/IndexSearcher.java (working copy)
@@ -22,6 +22,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.CorruptIndexException;
@@ -90,8 +91,13 @@
public Document doc(int i) throws CorruptIndexException, IOException {
return reader.document(i);
}
-
+
// inherit javadoc
+ public Document doc(int i, FieldSelector fieldSelector) throws CorruptIndexException, IOException {
+ return reader.document(i, fieldSelector);
+ }
+
+ // inherit javadoc
public int maxDoc() throws IOException {
return reader.maxDoc();
}
Index: src/java/org/apache/lucene/search/MultiSearcher.java
===================================================================
--- src/java/org/apache/lucene/search/MultiSearcher.java (revision 514225)
+++ src/java/org/apache/lucene/search/MultiSearcher.java (working copy)
@@ -24,6 +24,7 @@
import java.util.Set;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.CorruptIndexException;
@@ -85,6 +86,10 @@
public Document doc(int i) {
throw new UnsupportedOperationException();
}
+
+ public Document doc(int i, FieldSelector fieldSelector) {
+ throw new UnsupportedOperationException();
+ }
public Explanation explain(Weight weight,int doc) {
throw new UnsupportedOperationException();
@@ -148,7 +153,12 @@
return searchables[i].doc(n - starts[i]); // dispatch to searcher
}
-
+ // inherit javadoc
+ public Document doc(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException {
+ int i = subSearcher(n); // find searcher index
+ return searchables[i].doc(n - starts[i], fieldSelector); // dispatch to searcher
+ }
+
/** Returns index of the searcher for document n in the array
* used to construct this searcher. */
public int subSearcher(int n) { // find searcher for doc n:
Index: src/java/org/apache/lucene/search/RemoteSearchable.java
===================================================================
--- src/java/org/apache/lucene/search/RemoteSearchable.java (revision 514225)
+++ src/java/org/apache/lucene/search/RemoteSearchable.java (working copy)
@@ -18,6 +18,7 @@
*/
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.CorruptIndexException;
@@ -81,6 +82,10 @@
return local.doc(i);
}
+ public Document doc(int i, FieldSelector fieldSelector) throws CorruptIndexException, IOException {
+ return local.doc(i, fieldSelector);
+ }
+
public Query rewrite(Query original) throws IOException {
return local.rewrite(original);
}
Index: src/java/org/apache/lucene/search/Searchable.java
===================================================================
--- src/java/org/apache/lucene/search/Searchable.java (revision 514225)
+++ src/java/org/apache/lucene/search/Searchable.java (working copy)
@@ -18,6 +18,7 @@
*/
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.CorruptIndexException;
@@ -98,6 +99,29 @@
*/
Document doc(int i) throws CorruptIndexException, IOException;
+ /**
+ * Get the {@link org.apache.lucene.document.Document} at the nth position. The {@link org.apache.lucene.document.FieldSelector}
+ * may be used to determine what {@link org.apache.lucene.document.Field}s to load and how they should be loaded.
+ *
+ * NOTE: If the underlying Reader (more specifically, the underlying FieldsReader) is closed before the lazy {@link org.apache.lucene.document.Field} is
+ * loaded an exception may be thrown. If you want the value of a lazy {@link org.apache.lucene.document.Field} to be available after closing you must
+ * explicitly load it or fetch the Document again with a new loader.
+ *
+ *
+ * @param n Get the document at the nth position
+ * @param fieldSelector The {@link org.apache.lucene.document.FieldSelector} to use to determine what Fields should be loaded on the Document. May be null, in which case all Fields will be loaded.
+ * @return The stored fields of the {@link org.apache.lucene.document.Document} at the nth position
+ * @throws CorruptIndexException if the index is corrupt
+ * @throws IOException if there is a low-level IO error
+ *
+ * @see IndexReader#document(int, FieldSelector)
+ * @see org.apache.lucene.document.Fieldable
+ * @see org.apache.lucene.document.FieldSelector
+ * @see org.apache.lucene.document.SetBasedFieldSelector
+ * @see org.apache.lucene.document.LoadFirstFieldSelector
+ */
+ Document doc(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException;
+
/** Expert: called to re-write queries into primitive queries.
* @throws BooleanQuery.TooManyClauses
*/