Index: lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java =================================================================== --- lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java (revision 1360283) +++ lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java (working copy) @@ -21,6 +21,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; @@ -80,7 +81,7 @@ IndexSearcher indexSearcher = new IndexSearcher(directoryReader); TopDocs result = indexSearcher.search(new MatchAllDocsQuery(), 10); assertTrue(result.totalHits > 0); - Document d = indexSearcher.doc(result.scoreDocs[0].doc); + StoredDocument d = indexSearcher.doc(result.scoreDocs[0].doc); assertNotNull(d); assertNotNull(d.getField("title")); assertEquals(dummyTitle, d.getField("title").stringValue()); @@ -100,7 +101,7 @@ directoryReader = DirectoryReader.open(dir); indexSearcher = new IndexSearcher(directoryReader); result = indexSearcher.search(new MatchAllDocsQuery(), 10); - Document d1 = indexSearcher.doc(result.scoreDocs[1].doc); + StoredDocument d1 = indexSearcher.doc(result.scoreDocs[1].doc); assertNotNull(d1); assertNotNull(d1.getField("title")); assertEquals(dogmasTitle, d1.getField("title").stringValue()); Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java =================================================================== --- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java (revision 1360283) +++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java (working copy) @@ -231,6 +231,7 @@ // Set ID_FIELD FieldType ft = new FieldType(valType); ft.setIndexed(true); + ft.setStored(true); Field idField = ds.getField(ID_FIELD, ft); int id; Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java =================================================================== --- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java (revision 1360283) +++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java (working copy) @@ -19,6 +19,7 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexReader; /** @@ -26,5 +27,5 @@ */ public abstract class BenchmarkHighlighter { public abstract int doHighlight( IndexReader reader, int doc, String field, - Document document, Analyzer analyzer, String text ) throws Exception ; + StoredDocument document, Analyzer analyzer, String text ) throws Exception ; } Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java =================================================================== --- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java (revision 1360283) +++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java (working copy) @@ -28,10 +28,12 @@ import org.apache.lucene.benchmark.byTask.PerfRunData; import org.apache.lucene.benchmark.byTask.feeds.QueryMaker; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.MultiFields; +import org.apache.lucene.index.StorableField; import org.apache.lucene.search.Collector; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.MultiTermQuery; @@ -96,7 +98,7 @@ // optionally warm and add num docs traversed to count if (withWarm()) { - Document doc = null; + StoredDocument doc = null; Bits liveDocs = MultiFields.getLiveDocs(reader); for (int m = 0; m < reader.maxDoc(); m++) { if (null == liveDocs || liveDocs.get(m)) { @@ -142,7 +144,7 @@ System.out.println("numDocs() = " + reader.numDocs()); for(int i=0;irandom words for second field", result); Index: lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java =================================================================== --- lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (revision 1360283) +++ lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (working copy) @@ -119,11 +119,11 @@ assertEquals(1, group.totalHits); assertFalse(Float.isNaN(group.score)); - Document childDoc = s.doc(group.scoreDocs[0].doc); + StoredDocument childDoc = s.doc(group.scoreDocs[0].doc); //System.out.println(" doc=" + group.scoreDocs[0].doc); assertEquals("java", childDoc.get("skill")); assertNotNull(group.groupValue); - Document parentDoc = s.doc(group.groupValue); + StoredDocument parentDoc = s.doc(group.groupValue); assertEquals("Lisa", parentDoc.get("name")); @@ -247,7 +247,7 @@ } } - private Document getParentDoc(IndexReader reader, Filter parents, int childDocID) throws IOException { + private StoredDocument getParentDoc(IndexReader reader, Filter parents, int childDocID) throws IOException { final List leaves = reader.getTopReaderContext().leaves(); final int subIndex = ReaderUtil.subIndex(childDocID, leaves); final AtomicReaderContext leaf = leaves.get(subIndex); @@ -563,7 +563,7 @@ System.out.println("\nTEST: normal index gets " + results.totalHits + " hits"); final ScoreDoc[] hits = results.scoreDocs; for(int hitIDX=0;hitIDX group = groupDocs[joinGroupUpto++]; final ScoreDoc[] groupHits = group.scoreDocs; assertNotNull(group.groupValue); - final Document parentDoc = joinR.document(group.groupValue); + final StoredDocument parentDoc = joinR.document(group.groupValue); final String parentID = parentDoc.get("parentID"); //System.out.println("GROUP groupDoc=" + group.groupDoc + " parent=" + parentDoc); assertNotNull(parentID); assertTrue(groupHits.length > 0); for(int hitIDX=0;hitIDX group = jobResults.groups[0]; assertEquals(1, group.totalHits); - Document childJobDoc = s.doc(group.scoreDocs[0].doc); + StoredDocument childJobDoc = s.doc(group.scoreDocs[0].doc); //System.out.println(" doc=" + group.scoreDocs[0].doc); assertEquals("java", childJobDoc.get("skill")); assertNotNull(group.groupValue); - Document parentDoc = s.doc(group.groupValue); + StoredDocument parentDoc = s.doc(group.groupValue); assertEquals("Lisa", parentDoc.get("name")); } @@ -933,10 +933,10 @@ final GroupDocs qGroup = qualificationResults.groups[0]; assertEquals(1, qGroup.totalHits); - Document childQualificationDoc = s.doc(qGroup.scoreDocs[0].doc); + StoredDocument childQualificationDoc = s.doc(qGroup.scoreDocs[0].doc); assertEquals("maths", childQualificationDoc.get("qualification")); assertNotNull(qGroup.groupValue); - Document parentDoc = s.doc(qGroup.groupValue); + StoredDocument parentDoc = s.doc(qGroup.groupValue); assertEquals("Lisa", parentDoc.get("name")); Index: lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java =================================================================== --- lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java (revision 1360283) +++ lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java (working copy) @@ -25,8 +25,8 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.index.FieldInfo; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableFieldType; +import org.apache.lucene.index.StorableField; import org.apache.lucene.util.BytesRef; /** Defers actually loading a field's value until you ask @@ -38,7 +38,7 @@ private final int docID; // null until first field is loaded - private Document doc; + private StoredDocument doc; private Map fields = new HashMap(); @@ -47,7 +47,7 @@ this.docID = docID; } - public IndexableField getField(FieldInfo fieldInfo) { + public StorableField getField(FieldInfo fieldInfo) { Integer num = fields.get(fieldInfo.number); if (num == null) { num = 0; @@ -59,7 +59,7 @@ return new LazyField(fieldInfo.name, num); } - private synchronized Document getDocument() { + private synchronized StoredDocument getDocument() { if (doc == null) { try { doc = reader.document(docID); @@ -71,7 +71,7 @@ return doc; } - private class LazyField implements IndexableField { + private class LazyField implements StorableField { private String name; private int num; @@ -86,11 +86,6 @@ } @Override - public float boost() { - return 1.0f; - } - - @Override public BytesRef binaryValue() { if (num == 0) { return getDocument().getField(name).binaryValue(); @@ -134,14 +129,5 @@ return getDocument().getFields(name)[num].fieldType(); } } - - @Override - public TokenStream tokenStream(Analyzer analyzer) throws IOException { - if (num == 0) { - return getDocument().getField(name).tokenStream(analyzer); - } else { - return getDocument().getFields(name)[num].tokenStream(analyzer); - } - } } } Index: lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java =================================================================== --- lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java (revision 1360283) +++ lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java (working copy) @@ -19,6 +19,7 @@ import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCase; @@ -68,7 +69,7 @@ IndexReader ir; ir = DirectoryReader.open(dirs[0]); assertTrue(ir.numDocs() - NUM_DOCS / 3 <= 1); // rounding error - Document doc = ir.document(0); + StoredDocument doc = ir.document(0); assertEquals("0", doc.get("id")); TermsEnum te = MultiFields.getTerms(ir, "id").iterator(null); assertEquals(TermsEnum.SeekStatus.NOT_FOUND, te.seekCeil(new BytesRef("1"))); @@ -113,7 +114,7 @@ IndexReader ir; ir = DirectoryReader.open(dirs[0]); assertTrue(ir.numDocs() - NUM_DOCS / 3 <= 1); - Document doc = ir.document(0); + StoredDocument doc = ir.document(0); assertEquals("0", doc.get("id")); int start = ir.numDocs(); ir.close(); Index: lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java =================================================================== --- lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java (revision 1360283) +++ lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java (working copy) @@ -22,10 +22,12 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.Fields; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.MultiFields; +import org.apache.lucene.index.StorableField; import org.apache.lucene.index.Term; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; @@ -715,9 +717,9 @@ // field does not store term vector info if (vector == null) { - Document d = ir.document(docNum); - IndexableField fields[] = d.getFields(fieldName); - for (IndexableField field : fields) { + StoredDocument d = ir.document(docNum); + StorableField[] fields = d.getFields(fieldName); + for (StorableField field : fields) { final String stringValue = field.stringValue(); if (stringValue != null) { addTermFrequencies(new StringReader(stringValue), termFreqMap, fieldName); Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java =================================================================== --- lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java (revision 1360283) +++ lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java (working copy) @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; @@ -100,7 +101,7 @@ TopDocs td = searcher.search(q, 10); ScoreDoc[] sd = td.scoreDocs; for (int i = 0; i < sd.length; i++) { - Document doc = searcher.doc(sd[i].doc); + StoredDocument doc = searcher.doc(sd[i].doc); String id = doc.get("id"); assertTrue(qString + "matched doc#" + id + " not expected", expecteds .contains(id)); Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java =================================================================== --- lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (revision 1360283) +++ lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (working copy) @@ -24,6 +24,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.IntField; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; @@ -232,7 +233,7 @@ System.out.println("=========" + qType + "============"); ScoreDoc[] scoreDocs = hits.scoreDocs; for (int i = 0; i < Math.min(numDocs, hits.totalHits); i++) { - Document ldoc = searcher.doc(scoreDocs[i].doc); + StoredDocument ldoc = searcher.doc(scoreDocs[i].doc); System.out.println("[" + ldoc.get("date") + "]" + ldoc.get("contents")); } System.out.println(); Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java =================================================================== --- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java (revision 1360283) +++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java (working copy) @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.*; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; @@ -87,7 +88,7 @@ ScoreDoc[] hits = searcher.search(tq, df, 1000).scoreDocs; for (ScoreDoc hit : hits) { - Document d = searcher.doc(hit.doc); + StoredDocument d = searcher.doc(hit.doc); String url = d.get(KEY_FIELD); assertFalse("No duplicate urls should be returned", results.contains(url)); results.add(url); @@ -101,7 +102,7 @@ boolean dupsFound = false; for (ScoreDoc hit : hits) { - Document d = searcher.doc(hit.doc); + StoredDocument d = searcher.doc(hit.doc); String url = d.get(KEY_FIELD); if (!dupsFound) dupsFound = results.contains(url); @@ -118,7 +119,7 @@ assertTrue("Filtered searching should have found some matches", hits.length > 0); for (ScoreDoc hit : hits) { - Document d = searcher.doc(hit.doc); + StoredDocument d = searcher.doc(hit.doc); String url = d.get(KEY_FIELD); assertFalse("No duplicate urls should be returned", results.contains(url)); results.add(url); @@ -132,7 +133,7 @@ ScoreDoc[] hits = searcher.search(tq, df, 1000).scoreDocs; assertTrue("Filtered searching should have found some matches", hits.length > 0); for (ScoreDoc hit : hits) { - Document d = searcher.doc(hit.doc); + StoredDocument d = searcher.doc(hit.doc); String url = d.get(KEY_FIELD); DocsEnum td = _TestUtil.docs(random(), reader, KEY_FIELD, @@ -156,7 +157,7 @@ ScoreDoc[] hits = searcher.search(tq, df, 1000).scoreDocs; assertTrue("Filtered searching should have found some matches", hits.length > 0); for (ScoreDoc hit : hits) { - Document d = searcher.doc(hit.doc); + StoredDocument d = searcher.doc(hit.doc); String url = d.get(KEY_FIELD); DocsEnum td = _TestUtil.docs(random(), reader, KEY_FIELD, Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java =================================================================== --- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java (revision 1360283) +++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java (working copy) @@ -21,6 +21,7 @@ import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; @@ -88,7 +89,7 @@ TopDocs topDocs = searcher.search(flt, 1); ScoreDoc[] sd = topDocs.scoreDocs; assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0)); - Document doc = searcher.doc(sd[0].doc); + StoredDocument doc = searcher.doc(sd[0].doc); assertEquals("Should match most similar not most rare variant", "2", doc.get("id")); } @@ -104,7 +105,7 @@ TopDocs topDocs = searcher.search(flt, 1); ScoreDoc[] sd = topDocs.scoreDocs; assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0)); - Document doc = searcher.doc(sd[0].doc); + StoredDocument doc = searcher.doc(sd[0].doc); assertEquals("Should match most similar when using 2 words", "2", doc.get("id")); } @@ -119,7 +120,7 @@ TopDocs topDocs = searcher.search(flt, 1); ScoreDoc[] sd = topDocs.scoreDocs; assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0)); - Document doc = searcher.doc(sd[0].doc); + StoredDocument doc = searcher.doc(sd[0].doc); assertEquals("Should match most similar when using 2 words", "2", doc.get("id")); } Index: lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java =================================================================== --- lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java (revision 1360283) +++ lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java (working copy) @@ -18,6 +18,7 @@ package org.apache.lucene.spatial; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; @@ -130,11 +131,11 @@ protected static class SearchResult { public float score; - public Document document; + public StoredDocument document; - public SearchResult(float score, Document document) { + public SearchResult(float score, StoredDocument storedDocument) { this.score = score; - this.document = document; + this.document = storedDocument; } @Override Index: solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java =================================================================== --- solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java (revision 1360283) +++ solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java (working copy) @@ -27,6 +27,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute; import org.apache.lucene.collation.ICUCollationKeyAnalyzer; +import org.apache.lucene.index.GeneralField; import org.apache.lucene.index.IndexableField; import org.apache.lucene.search.Query; import org.apache.lucene.search.SortField; @@ -210,7 +211,7 @@ } @Override - public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException { + public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException { writer.writeStr(name, f.stringValue(), true); } Index: solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java =================================================================== --- solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java (working copy) @@ -28,6 +28,7 @@ import org.apache.lucene.analysis.util.TokenizerFactory; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.*; import org.apache.lucene.index.FieldInfo.IndexOptions; import org.apache.lucene.search.DocIdSetIterator; @@ -132,7 +133,7 @@ if( style != null && style != ShowStyle.DOC ) { throw new SolrException(ErrorCode.BAD_REQUEST, "missing doc param for doc style"); } - Document doc = null; + StoredDocument doc = null; try { doc = reader.document( docId ); } @@ -169,7 +170,7 @@ /** * @return a string representing a IndexableField's flags. */ - private static String getFieldFlags( IndexableField f ) + private static String getFieldFlags( StorableField f ) { IndexOptions opts = (f == null) ? null : f.fieldType().indexOptions(); @@ -238,7 +239,7 @@ return key; } - private static SimpleOrderedMap getDocumentFieldsInfo( Document doc, int docId, IndexReader reader, + private static SimpleOrderedMap getDocumentFieldsInfo( StoredDocument doc, int docId, IndexReader reader, IndexSchema schema ) throws IOException { final CharsRef spare = new CharsRef(); @@ -342,13 +343,13 @@ if(sfield != null && sfield.indexed() ) { // In the pre-4.0 days, this did a veeeery expensive range query. But we can be much faster now, // so just do this all the time. - Document doc = getFirstLiveDoc(reader, fieldName, terms); + StoredDocument doc = getFirstLiveDoc(reader, fieldName, terms); if( doc != null ) { // Found a document with this field try { - IndexableField fld = doc.getField( fieldName ); + StorableField fld = doc.getField( fieldName ); if( fld != null ) { fieldMap.add("index", getFieldFlags(fld)); } @@ -376,7 +377,7 @@ // Just get a document with the term in it, the first one will do! // Is there a better way to do this? Shouldn't actually be very costly // to do it this way. - private static Document getFirstLiveDoc(AtomicReader reader, String fieldName, Terms terms) throws IOException { + private static StoredDocument getFirstLiveDoc(AtomicReader reader, String fieldName, Terms terms) throws IOException { DocsEnum docsEnum = null; TermsEnum termsEnum = terms.iterator(null); BytesRef text; Index: solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java =================================================================== --- solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java (working copy) @@ -18,7 +18,9 @@ */ import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexableField; +import org.apache.lucene.index.StorableField; import org.apache.lucene.index.Term; import org.apache.lucene.util.BytesRef; import org.apache.solr.client.solrj.SolrResponse; @@ -169,7 +171,7 @@ int docid = searcher.getFirstMatch(new Term(idField.getName(), idBytes)); if (docid < 0) continue; - Document luceneDocument = searcher.doc(docid); + StoredDocument luceneDocument = searcher.doc(docid); SolrDocument doc = toSolrDoc(luceneDocument, req.getSchema()); if( transformer != null ) { transformer.transform(doc, docid); @@ -236,7 +238,7 @@ int docid = searcher.getFirstMatch(new Term(idField.getName(), idBytes)); if (docid < 0) return null; - Document luceneDocument = searcher.doc(docid); + StoredDocument luceneDocument = searcher.doc(docid); sid = toSolrInputDocument(luceneDocument, core.getSchema()); } } finally { @@ -248,9 +250,9 @@ return sid; } - private static SolrInputDocument toSolrInputDocument(Document doc, IndexSchema schema) { + private static SolrInputDocument toSolrInputDocument(StoredDocument doc, IndexSchema schema) { SolrInputDocument out = new SolrInputDocument(); - for( IndexableField f : doc.getFields() ) { + for( StorableField f : doc.getFields() ) { String fname = f.name(); SchemaField sf = schema.getFieldOrNull(f.name()); Object val = null; @@ -270,9 +272,9 @@ } - private static SolrDocument toSolrDoc(Document doc, IndexSchema schema) { + private static SolrDocument toSolrDoc(StoredDocument doc, IndexSchema schema) { SolrDocument out = new SolrDocument(); - for( IndexableField f : doc.getFields() ) { + for( StorableField f : doc.getFields() ) { // Make sure multivalued fields are represented as lists Object existing = out.get(f.name()); if (existing == null) { @@ -299,10 +301,10 @@ List fields = doc.getFields(); // copy the stored fields only - Document out = new Document(); + StoredDocument out = new StoredDocument(); for (IndexableField f : doc.getFields()) { if (f.fieldType().stored()) { - out.add(f); + out.add((StorableField) f); } } Index: solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java =================================================================== --- solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java (working copy) @@ -30,6 +30,7 @@ import java.util.regex.Pattern; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.queryparser.classic.ParseException; @@ -342,7 +343,7 @@ public DocListAndSet getMoreLikeThis( int id, int start, int rows, List filters, List terms, int flags ) throws IOException { - Document doc = reader.document(id); + StoredDocument doc = reader.document(id); rawMLTQuery = mlt.like(id); boostedMLTQuery = getBoostedQuery( rawMLTQuery ); if( terms != null ) { Index: solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java =================================================================== --- solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java (working copy) @@ -33,7 +33,9 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexableField; +import org.apache.lucene.index.StorableField; import org.apache.lucene.search.Query; import org.apache.lucene.search.highlight.*; import org.apache.lucene.search.vectorhighlight.BoundaryScanner; @@ -391,7 +393,7 @@ DocIterator iterator = docs.iterator(); for (int i = 0; i < docs.size(); i++) { int docId = iterator.nextDoc(); - Document doc = searcher.doc(docId, fset); + StoredDocument doc = searcher.doc(docId, fset); NamedList docSummaries = new SimpleOrderedMap(); for (String fieldName : fieldNames) { fieldName = fieldName.trim(); @@ -423,7 +425,7 @@ } private void doHighlightingByHighlighter( Query query, SolrQueryRequest req, NamedList docSummaries, - int docId, Document doc, String fieldName ) throws IOException { + int docId, StoredDocument doc, String fieldName ) throws IOException { final SolrIndexSearcher searcher = req.getSearcher(); final IndexSchema schema = searcher.getSchema(); @@ -438,9 +440,9 @@ // END: Hack SolrParams params = req.getParams(); - IndexableField[] docFields = doc.getFields(fieldName); + StorableField[] docFields = doc.getFields(fieldName); List listFields = new ArrayList(); - for (IndexableField field : docFields) { + for (StorableField field : docFields) { listFields.add(field.stringValue()); } @@ -545,7 +547,7 @@ } private void doHighlightingByFastVectorHighlighter( FastVectorHighlighter highlighter, FieldQuery fieldQuery, - SolrQueryRequest req, NamedList docSummaries, int docId, Document doc, + SolrQueryRequest req, NamedList docSummaries, int docId, StoredDocument doc, String fieldName ) throws IOException { SolrParams params = req.getParams(); SolrFragmentsBuilder solrFb = getSolrFragmentsBuilder( fieldName, params ); @@ -563,12 +565,12 @@ alternateField( docSummaries, params, doc, fieldName ); } - private void alternateField( NamedList docSummaries, SolrParams params, Document doc, String fieldName ){ + private void alternateField( NamedList docSummaries, SolrParams params, StoredDocument doc, String fieldName ){ String alternateField = params.getFieldParam(fieldName, HighlightParams.ALTERNATE_FIELD); if (alternateField != null && alternateField.length() > 0) { - IndexableField[] docFields = doc.getFields(alternateField); + StorableField[] docFields = doc.getFields(alternateField); List listFields = new ArrayList(); - for (IndexableField field : docFields) { + for (StorableField field : docFields) { if (field.binaryValue() == null) listFields.add(field.stringValue()); } Index: solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java =================================================================== --- solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java (working copy) @@ -20,7 +20,9 @@ import java.util.*; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexableField; +import org.apache.lucene.index.StorableField; import org.apache.lucene.util.BytesRef; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.params.CommonParams; @@ -90,7 +92,7 @@ if( o instanceof IndexableField ) { if(schema == null) schema = solrQueryRequest.getSchema(); - IndexableField f = (IndexableField)o; + StorableField f = (StorableField)o; SchemaField sf = schema.getFieldOrNull(f.name()); try { o = getValue(sf, f); @@ -138,7 +140,7 @@ context.iterator = ids.iterator(); for (int i = 0; i < sz; i++) { int id = context.iterator.nextDoc(); - Document doc = searcher.doc(id, fnames); + StoredDocument doc = searcher.doc(id, fnames); SolrDocument sdoc = getDoc(doc); if( transformer != null ) { transformer.transform(sdoc, id); @@ -168,9 +170,9 @@ writeResultsBody( ctx, codec ); } - public SolrDocument getDoc(Document doc) { + public SolrDocument getDoc(StoredDocument doc) { SolrDocument solrDoc = new SolrDocument(); - for (IndexableField f : doc) { + for (StorableField f : doc) { String fieldName = f.name(); if( !returnFields.wantsField(fieldName) ) continue; @@ -198,7 +200,7 @@ return solrDoc; } - public Object getValue(SchemaField sf, IndexableField f) throws Exception { + public Object getValue(SchemaField sf, StorableField f) throws Exception { FieldType ft = null; if(sf != null) ft =sf.getType(); Index: solr/core/src/java/org/apache/solr/response/TextResponseWriter.java =================================================================== --- solr/core/src/java/org/apache/solr/response/TextResponseWriter.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/response/TextResponseWriter.java (working copy) @@ -22,7 +22,9 @@ import java.util.*; import org.apache.lucene.document.Document; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.index.IndexableField; +import org.apache.lucene.index.StorableField; import org.apache.lucene.util.BytesRef; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocumentList; @@ -123,8 +125,8 @@ } else if (val instanceof String) { writeStr(name, val.toString(), true); // micro-optimization... using toString() avoids a cast first - } else if (val instanceof IndexableField) { - IndexableField f = (IndexableField)val; + } else if (val instanceof StorableField) { + StorableField f = (StorableField)val; SchemaField sf = schema.getFieldOrNull( f.name() ); if( sf != null ) { sf.getType().write(this, name, f); @@ -155,8 +157,8 @@ writeBool(name, val.toString()); } else if (val instanceof Date) { writeDate(name,(Date)val); - } else if (val instanceof Document) { - SolrDocument doc = toSolrDocument( (Document)val ); + } else if (val instanceof StoredDocument) { + SolrDocument doc = toSolrDocument( (StoredDocument)val ); DocTransformer transformer = returnFields.getTransformer(); if( transformer != null ) { TransformContext context = new TransformContext(); @@ -224,10 +226,10 @@ writeEndDocumentList(); } - public final SolrDocument toSolrDocument( Document doc ) + public final SolrDocument toSolrDocument( StoredDocument doc ) { SolrDocument out = new SolrDocument(); - for( IndexableField f : doc) { + for( StorableField f : doc.getFields()) { // Make sure multivalued fields are represented as lists Object existing = out.get(f.name()); if (existing == null) { @@ -267,7 +269,7 @@ Set fnames = fields.getLuceneFieldNames(); for (int i=0; i document = new NamedList(); documents.add(document); - Document doc = retrieveDocument(uniqueField, scoreDoc.doc); + StoredDocument doc = retrieveDocument(uniqueField, scoreDoc.doc); document.add("id", uniqueField.getType().toExternal(doc.getField(uniqueField.getName()))); if (rb.getGroupingSpec().isNeedScore()) { document.add("score", scoreDoc.score); @@ -265,7 +266,7 @@ return queryResult; } - private Document retrieveDocument(final SchemaField uniqueField, int doc) throws IOException { + private StoredDocument retrieveDocument(final SchemaField uniqueField, int doc) throws IOException { DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(uniqueField.getName()); rb.req.getSearcher().doc(doc, visitor); return visitor.getDocument(); Index: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java =================================================================== --- solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java (revision 1360283) +++ solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java (working copy) @@ -31,6 +31,7 @@ import org.apache.lucene.document.IntField; import org.apache.lucene.document.LazyDocument; import org.apache.lucene.document.LongField; +import org.apache.lucene.document.StoredDocument; import org.apache.lucene.document.StoredField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.*; @@ -95,7 +96,7 @@ private final boolean cachingEnabled; private final SolrCache filterCache; private final SolrCache queryResultCache; - private final SolrCache documentCache; + private final SolrCache documentCache; private final SolrCache fieldValueCache; private final LuceneQueryOptimizer optimizer; @@ -433,7 +434,7 @@ // need to open up access to its Document... static class SetNonLazyFieldSelector extends StoredFieldVisitor { private Set fieldsToLoad; - final Document doc = new Document(); + final StoredDocument doc = new StoredDocument(); final LazyDocument lazyDoc; SetNonLazyFieldSelector(Set toLoad, IndexReader reader, int docID) { @@ -502,7 +503,7 @@ * Retrieve the {@link Document} instance corresponding to the document id. */ @Override - public Document doc(int i) throws IOException { + public StoredDocument doc(int i) throws IOException { return doc(i, (Set)null); } @@ -522,9 +523,9 @@ * filter is provided, only the provided fields will be loaded (the * remainder will be available lazily). */ - public Document doc(int i, Set fields) throws IOException { + public StoredDocument doc(int i, Set fields) throws IOException { - Document d; + StoredDocument d; if (documentCache != null) { d = documentCache.get(i); if (d!=null) return d; @@ -549,14 +550,14 @@ * Takes a list of docs (the doc ids actually), and reads them into an array * of Documents. */ - public void readDocs(Document[] docs, DocList ids) throws IOException { + public void readDocs(StoredDocument[] docs, DocList ids) throws IOException { readDocs(docs, ids, null); } /** * Takes a list of docs (the doc ids actually) and a set of fields to load, * and reads them into an array of Documents. */ - public void readDocs(Document[] docs, DocList ids, Set fields) throws IOException { + public void readDocs(StoredDocument[] docs, DocList ids, Set fields) throws IOException { DocIterator iter = ids.iterator(); for (int i=0; i= 0); // we should have found the document, or it's tombstone - Document doc = r.document(docid); + StoredDocument doc = r.document(docid); long foundVal = Long.parseLong(doc.get(field)); if (foundVal < Math.abs(val)) { verbose("ERROR: id",id,"model_val=",val," foundVal=",foundVal,"reader=",reader);