LUCENE-3312: Apply patch 8

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1366638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-07-28 10:56:46 +00:00
parent 27aa2f6a28
commit a536dbf6ed
67 changed files with 284 additions and 226 deletions

View File

@ -21,6 +21,7 @@ import org.apache.lucene.analysis.BaseTokenStreamTestCase;
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 @@ public class UIMABaseAnalyzerTest extends BaseTokenStreamTestCase {
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 @@ public class UIMABaseAnalyzerTest extends BaseTokenStreamTestCase {
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());

View File

@ -231,6 +231,7 @@ public class DocMaker implements Closeable {
// Set ID_FIELD
FieldType ft = new FieldType(valType);
ft.setIndexed(true);
ft.setStored(true);
Field idField = ds.getField(ID_FIELD, ft);
int id;

View File

@ -19,6 +19,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
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 @@ import org.apache.lucene.index.IndexReader;
*/
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 ;
}

View File

@ -28,10 +28,12 @@ import org.apache.lucene.analysis.Analyzer;
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 @@ public abstract class ReadTask extends PerfTask {
// 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 @@ public abstract class ReadTask extends PerfTask {
System.out.println("numDocs() = " + reader.numDocs());
for(int i=0;i<hits.scoreDocs.length;i++) {
final int docID = hits.scoreDocs[i].doc;
final Document doc = reader.document(docID);
final StoredDocument doc = reader.document(docID);
System.out.println(" " + i + ": doc=" + docID + " score=" + hits.scoreDocs[i].score + " " + printHitsField + " =" + doc.get(printHitsField));
}
}
@ -163,7 +165,7 @@ public abstract class ReadTask extends PerfTask {
int id = scoreDocs[m].doc;
res++;
if (retrieve) {
Document document = retrieveDoc(reader, id);
StoredDocument document = retrieveDoc(reader, id);
res += document != null ? 1 : 0;
if (numHighlight > 0 && m < numHighlight) {
Collection<String> fieldsToHighlight = getFieldsToHighlight(document);
@ -193,7 +195,7 @@ public abstract class ReadTask extends PerfTask {
}
protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
protected StoredDocument retrieveDoc(IndexReader ir, int id) throws IOException {
return ir.document(id);
}
@ -296,10 +298,10 @@ public abstract class ReadTask extends PerfTask {
* @param document The Document
* @return A Collection of Field names (Strings)
*/
protected Collection<String> getFieldsToHighlight(Document document) {
List<IndexableField> fields = document.getFields();
protected Collection<String> getFieldsToHighlight(StoredDocument document) {
List<StorableField> fields = document.getFields();
Set<String> result = new HashSet<String>(fields.size());
for (final IndexableField f : fields) {
for (final StorableField f : fields) {
result.add(f.name());
}
return result;

View File

@ -21,6 +21,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.highlight.Highlighter;
@ -101,7 +102,7 @@ public class SearchTravRetHighlightTask extends SearchTravTask {
return new BenchmarkHighlighter(){
@Override
public int doHighlight(IndexReader reader, int doc, String field,
Document document, Analyzer analyzer, String text) throws Exception {
StoredDocument document, Analyzer analyzer, String text) throws Exception {
TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFrags);
return frag != null ? frag.length : 0;
@ -110,7 +111,7 @@ public class SearchTravRetHighlightTask extends SearchTravTask {
}
@Override
protected Collection<String> getFieldsToHighlight(Document document) {
protected Collection<String> getFieldsToHighlight(StoredDocument document) {
Collection<String> result = super.getFieldsToHighlight(document);
//if stored is false, then result will be empty, in which case just get all the param fields
if (paramFields.isEmpty() == false && result.isEmpty() == false) {

View File

@ -24,6 +24,7 @@ import java.util.StringTokenizer;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
/**
@ -54,7 +55,7 @@ public class SearchTravRetLoadFieldSelectorTask extends SearchTravTask {
@Override
protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
protected StoredDocument retrieveDoc(IndexReader ir, int id) throws IOException {
if (fieldsToLoad == null) {
return ir.document(id);
} else {

View File

@ -20,6 +20,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter;
@ -99,7 +100,7 @@ public class SearchTravRetVectorHighlightTask extends SearchTravTask {
return new BenchmarkHighlighter(){
@Override
public int doHighlight(IndexReader reader, int doc, String field,
Document document, Analyzer analyzer, String text) throws Exception {
StoredDocument document, Analyzer analyzer, String text) throws Exception {
final FieldQuery fq = highlighter.getFieldQuery( myq, reader);
String[] fragments = highlighter.getBestFragments(fq, reader, doc, field, fragSize, maxFrags);
return fragments != null ? fragments.length : 0;
@ -108,7 +109,7 @@ public class SearchTravRetVectorHighlightTask extends SearchTravTask {
}
@Override
protected Collection<String> getFieldsToHighlight(Document document) {
protected Collection<String> getFieldsToHighlight(StoredDocument document) {
Collection<String> result = super.getFieldsToHighlight(document);
//if stored is false, then result will be empty, in which case just get all the param fields
if (paramFields.isEmpty() == false && result.isEmpty() == false) {

View File

@ -27,6 +27,7 @@ import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.TokenSources;
import org.apache.lucene.search.Query;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import java.io.IOException;
@ -44,8 +45,8 @@ public class CountingHighlighterTestTask extends SearchTravRetHighlightTask {
}
@Override
protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
Document document = ir.document(id);
protected StoredDocument retrieveDoc(IndexReader ir, int id) throws IOException {
StoredDocument document = ir.document(id);
if (document != null) {
numDocsRetrieved++;
}
@ -57,7 +58,7 @@ public class CountingHighlighterTestTask extends SearchTravRetHighlightTask {
highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
return new BenchmarkHighlighter() {
@Override
public int doHighlight(IndexReader reader, int doc, String field, Document document, Analyzer analyzer, String text) throws Exception {
public int doHighlight(IndexReader reader, int doc, String field, StoredDocument document, Analyzer analyzer, String text) throws Exception {
TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFrags);
numHighlightedResults += frag != null ? frag.length : 0;

View File

@ -124,7 +124,7 @@ public final class Document implements IndexDocument{
*/
public final BytesRef[] getBinaryValues(String name) {
final List<BytesRef> result = new ArrayList<BytesRef>();
Iterator<StorableField> it = storedFieldsIterator();
Iterator<Field> it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@ -149,7 +149,7 @@ public final class Document implements IndexDocument{
* @return a <code>byte[]</code> containing the binary field value or <code>null</code>
*/
public final BytesRef getBinaryValue(String name) {
Iterator<StorableField> it = storedFieldsIterator();
Iterator<Field> it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@ -224,7 +224,7 @@ public final class Document implements IndexDocument{
*/
public final String[] getValues(String name) {
List<String> result = new ArrayList<String>();
Iterator<StorableField> it = storedFieldsIterator();
Iterator<Field> it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@ -249,7 +249,7 @@ public final class Document implements IndexDocument{
* the actual numeric field instance back, use {@link #getField}.
*/
public final String get(String name) {
Iterator<StorableField> it = storedFieldsIterator();
Iterator<Field> it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@ -277,7 +277,7 @@ public final class Document implements IndexDocument{
@Override
public Iterable<? extends IndexableField> indexableFields() {
Iterator<IndexableField> it = indexedFieldsIterator();
Iterator<Field> it = indexedFieldsIterator();
List<IndexableField> result = new ArrayList<IndexableField>();
while(it.hasNext()) {
@ -289,7 +289,7 @@ public final class Document implements IndexDocument{
@Override
public Iterable<? extends StorableField> storableFields() {
Iterator<StorableField> it = storedFieldsIterator();
Iterator<Field> it = storedFieldsIterator();
List<StorableField> result = new ArrayList<StorableField>();
while(it.hasNext()) {
@ -299,8 +299,8 @@ public final class Document implements IndexDocument{
return result;
}
public Iterator<StorableField> storedFieldsIterator() {
return new FilterIterator<StorableField, Field>(fields.iterator()) {
public Iterator<Field> storedFieldsIterator() {
return new FilterIterator<Field>(fields.iterator()) {
@Override
protected boolean predicateFunction(Field field) {
return field.type.stored();
@ -308,8 +308,8 @@ public final class Document implements IndexDocument{
};
}
public Iterator<IndexableField> indexedFieldsIterator() {
return new FilterIterator<IndexableField, Field>(fields.iterator()) {
public Iterator<Field> indexedFieldsIterator() {
return new FilterIterator<Field>(fields.iterator()) {
@Override
protected boolean predicateFunction(Field field) {
return field.type.indexed();

View File

@ -240,7 +240,7 @@ final class DocFieldProcessor extends DocConsumer {
docState, fp.fieldInfo);
DocValuesConsumer consumer = docValuesConsumer.docValuesConsumer;
if (docValuesConsumer.compatibility == null) {
consumer.add(docState.docID, (StorableField) field);
consumer.add(docState.docID, field);
docValuesConsumer.compatibility = new TypeCompatibility(dvType,
consumer.getValueSize());
} else if (docValuesConsumer.compatibility.isCompatible(dvType,

View File

@ -54,7 +54,7 @@ final class NormsConsumerPerField extends InvertedDocEndConsumerPerField impleme
StorableField field = norm.field();
// some similarity might not compute any norms
DocValuesConsumer consumer = getConsumer(norm.type());
consumer.add(docState.docID, (StorableField) field);
consumer.add(docState.docID, field);
}
}
}

View File

@ -20,15 +20,15 @@ import java.util.NoSuchElementException;
* the License.
*/
public abstract class FilterIterator<T, U extends T> implements Iterator<T> {
public abstract class FilterIterator<T> implements Iterator<T> {
private Iterator<U> iterator;
private Iterator<T> iterator;
private T next = null;
private boolean nextIsSet = false;
protected abstract boolean predicateFunction(U field);
protected abstract boolean predicateFunction(T field);
public FilterIterator(Iterator<U> baseIterator) {
public FilterIterator(Iterator<T> baseIterator) {
this.iterator = baseIterator;
}
@ -56,7 +56,7 @@ public abstract class FilterIterator<T, U extends T> implements Iterator<T> {
private boolean setNext() {
while (iterator.hasNext()) {
U object = iterator.next();
T object = iterator.next();
if (predicateFunction(object)) {
next = object;
nextIsSet = true;

View File

@ -192,11 +192,14 @@ public class TestIndexableField extends LuceneTestCase {
@Override
public boolean hasNext() {
if (fieldUpto >= fieldCount) return false;
next = null;
if (fieldUpto > 1)
if (fieldUpto == 0) {
fieldUpto = 1;
next = newStringField("id", ""+finalDocCount, Field.Store.YES);
} else {
next = new MyField(finalBaseCount + (fieldUpto++-1));
else
fieldUpto = 2;
}
if (next != null && next.fieldType().indexed()) return true;
else return this.hasNext();

View File

@ -32,6 +32,7 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexReader;
@ -57,7 +58,7 @@ public class TokenSources {
* and get the vector from
* @param docId The docId to retrieve.
* @param field The field to retrieve on the document
* @param doc The document to fall back on
* @param document The document to fall back on
* @param analyzer The analyzer to use for creating the TokenStream if the
* vector doesn't exist
* @return The {@link org.apache.lucene.analysis.TokenStream} for the
@ -67,7 +68,7 @@ public class TokenSources {
*/
public static TokenStream getAnyTokenStream(IndexReader reader, int docId,
String field, Document doc, Analyzer analyzer) throws IOException {
String field, StoredDocument document, Analyzer analyzer) throws IOException {
TokenStream ts = null;
Fields vectors = reader.getTermVectors(docId);
@ -80,7 +81,7 @@ public class TokenSources {
// No token info stored so fall back to analyzing raw content
if (ts == null) {
ts = getTokenStream(doc, field, analyzer);
ts = getTokenStream(document, field, analyzer);
}
return ts;
}
@ -298,11 +299,11 @@ public class TokenSources {
// convenience method
public static TokenStream getTokenStream(IndexReader reader, int docId,
String field, Analyzer analyzer) throws IOException {
Document doc = reader.document(docId);
StoredDocument doc = reader.document(docId);
return getTokenStream(doc, field, analyzer);
}
public static TokenStream getTokenStream(Document doc, String field,
public static TokenStream getTokenStream(StoredDocument doc, String field,
Analyzer analyzer) {
String contents = doc.get(field);
if (contents == null) {

View File

@ -37,6 +37,7 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
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.document.StoredField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
@ -97,7 +98,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
for (int i = 0; i < hits.scoreDocs.length; i++) {
Document doc = searcher.doc(hits.scoreDocs[i].doc);
StoredDocument doc = searcher.doc(hits.scoreDocs[i].doc);
String storedField = doc.get(FIELD_NAME);
TokenStream stream = TokenSources.getAnyTokenStream(searcher
@ -1656,7 +1657,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
TopDocs hits = searcher.search(query, null, 10);
for( int i = 0; i < hits.totalHits; i++ ){
Document doc = searcher.doc( hits.scoreDocs[i].doc );
StoredDocument doc = searcher.doc( hits.scoreDocs[i].doc );
String result = h.getBestFragment( a, "t_text1", doc.get( "t_text1" ));
if (VERBOSE) System.out.println("result:" + result);
assertEquals("more <B>random</B> words for second field", result);

View File

@ -119,11 +119,11 @@ public class TestBlockJoin extends LuceneTestCase {
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 @@ public class TestBlockJoin extends LuceneTestCase {
}
}
private Document getParentDoc(IndexReader reader, Filter parents, int childDocID) throws IOException {
private StoredDocument getParentDoc(IndexReader reader, Filter parents, int childDocID) throws IOException {
final List<AtomicReaderContext> leaves = reader.getTopReaderContext().leaves();
final int subIndex = ReaderUtil.subIndex(childDocID, leaves);
final AtomicReaderContext leaf = leaves.get(subIndex);
@ -563,7 +563,7 @@ public class TestBlockJoin extends LuceneTestCase {
System.out.println("\nTEST: normal index gets " + results.totalHits + " hits");
final ScoreDoc[] hits = results.scoreDocs;
for(int hitIDX=0;hitIDX<hits.length;hitIDX++) {
final Document doc = s.doc(hits[hitIDX].doc);
final StoredDocument doc = s.doc(hits[hitIDX].doc);
//System.out.println(" score=" + hits[hitIDX].score + " parentID=" + doc.get("parentID") + " childID=" + doc.get("childID") + " (docID=" + hits[hitIDX].doc + ")");
System.out.println(" parentID=" + doc.get("parentID") + " childID=" + doc.get("childID") + " (docID=" + hits[hitIDX].doc + ")");
FieldDoc fd = (FieldDoc) hits[hitIDX];
@ -617,10 +617,10 @@ public class TestBlockJoin extends LuceneTestCase {
}
assertNotNull(group.groupValue);
final Document parentDoc = joinS.doc(group.groupValue);
final StoredDocument parentDoc = joinS.doc(group.groupValue);
System.out.println(" group parentID=" + parentDoc.get("parentID") + " (docID=" + group.groupValue + ")");
for(int hitIDX=0;hitIDX<group.scoreDocs.length;hitIDX++) {
final Document doc = joinS.doc(group.scoreDocs[hitIDX].doc);
final StoredDocument doc = joinS.doc(group.scoreDocs[hitIDX].doc);
//System.out.println(" score=" + group.scoreDocs[hitIDX].score + " childID=" + doc.get("childID") + " (docID=" + group.scoreDocs[hitIDX].doc + ")");
System.out.println(" childID=" + doc.get("childID") + " child0=" + doc.get("child0") + " (docID=" + group.scoreDocs[hitIDX].doc + ")");
}
@ -635,7 +635,7 @@ public class TestBlockJoin extends LuceneTestCase {
TopDocs b = joinS.search(childJoinQuery, 10);
for (ScoreDoc hit : b.scoreDocs) {
Explanation explanation = joinS.explain(childJoinQuery, hit.doc);
Document document = joinS.doc(hit.doc - 1);
StoredDocument document = joinS.doc(hit.doc - 1);
int childId = Integer.parseInt(document.get("childID"));
assertTrue(explanation.isMatch());
assertEquals(hit.score, explanation.getValue(), 0.0f);
@ -763,7 +763,7 @@ public class TestBlockJoin extends LuceneTestCase {
if (VERBOSE) {
System.out.println(" " + results2.totalHits + " totalHits:");
for(ScoreDoc sd : results2.scoreDocs) {
final Document doc = s.doc(sd.doc);
final StoredDocument doc = s.doc(sd.doc);
System.out.println(" childID=" + doc.get("childID") + " parentID=" + doc.get("parentID") + " docID=" + sd.doc);
}
}
@ -777,8 +777,8 @@ public class TestBlockJoin extends LuceneTestCase {
if (VERBOSE) {
System.out.println(" " + joinResults2.totalHits + " totalHits:");
for(ScoreDoc sd : joinResults2.scoreDocs) {
final Document doc = joinS.doc(sd.doc);
final Document parentDoc = getParentDoc(joinR, parentsFilter, sd.doc);
final StoredDocument doc = joinS.doc(sd.doc);
final StoredDocument parentDoc = getParentDoc(joinR, parentsFilter, sd.doc);
System.out.println(" childID=" + doc.get("childID") + " parentID=" + parentDoc.get("parentID") + " docID=" + sd.doc);
}
}
@ -798,8 +798,8 @@ public class TestBlockJoin extends LuceneTestCase {
for(int hitCount=0;hitCount<results.scoreDocs.length;hitCount++) {
ScoreDoc hit = results.scoreDocs[hitCount];
ScoreDoc joinHit = joinResults.scoreDocs[hitCount];
Document doc1 = r.document(hit.doc);
Document doc2 = joinR.document(joinHit.doc);
StoredDocument doc1 = r.document(hit.doc);
StoredDocument doc2 = joinR.document(joinHit.doc);
assertEquals("hit " + hitCount + " differs",
doc1.get("childID"), doc2.get("childID"));
// don't compare scores -- they are expected to differ
@ -826,14 +826,14 @@ public class TestBlockJoin extends LuceneTestCase {
final GroupDocs<Integer> 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<groupHits.length;hitIDX++) {
final Document nonJoinHit = r.document(hits[resultUpto++].doc);
final Document joinHit = joinR.document(groupHits[hitIDX].doc);
final StoredDocument nonJoinHit = r.document(hits[resultUpto++].doc);
final StoredDocument joinHit = joinR.document(groupHits[hitIDX].doc);
assertEquals(parentID,
nonJoinHit.get("parentID"));
assertEquals(joinHit.get("childID"),
@ -916,11 +916,11 @@ public class TestBlockJoin extends LuceneTestCase {
final GroupDocs<Integer> 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 @@ public class TestBlockJoin extends LuceneTestCase {
final GroupDocs<Integer> 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"));

View File

@ -25,8 +25,8 @@ import org.apache.lucene.analysis.Analyzer;
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 @@ public class LazyDocument {
private final int docID;
// null until first field is loaded
private Document doc;
private StoredDocument doc;
private Map<Integer,Integer> fields = new HashMap<Integer,Integer>();
@ -47,7 +47,7 @@ public class LazyDocument {
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 @@ public class LazyDocument {
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 @@ public class LazyDocument {
return doc;
}
private class LazyField implements IndexableField {
private class LazyField implements StorableField {
private String name;
private int num;
@ -85,11 +85,6 @@ public class LazyDocument {
return name;
}
@Override
public float boost() {
return 1.0f;
}
@Override
public BytesRef binaryValue() {
if (num == 0) {
@ -134,14 +129,5 @@ public class LazyDocument {
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);
}
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.lucene.index;
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 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
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 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
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();

View File

@ -22,10 +22,12 @@ import org.apache.lucene.analysis.Analyzer;
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 @@ public final class MoreLikeThis {
// 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);

View File

@ -23,6 +23,7 @@ import org.apache.lucene.analysis.Analyzer;
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 @@ public class TestComplexPhraseQuery extends LuceneTestCase {
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));

View File

@ -24,6 +24,7 @@ import org.apache.lucene.analysis.MockTokenizer;
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 @@ public class TestParser extends LuceneTestCase {
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();

View File

@ -23,6 +23,7 @@ import java.util.HashSet;
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 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 @@ public class DuplicateFilterTest extends LuceneTestCase {
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,

View File

@ -21,6 +21,7 @@ import org.apache.lucene.analysis.Analyzer;
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 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
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 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
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 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
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"));
}

View File

@ -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 @@ public abstract class SpatialTestCase extends LuceneTestCase {
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

View File

@ -27,6 +27,7 @@ import org.apache.lucene.analysis.Analyzer;
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 @@ public class ICUCollationField extends FieldType {
}
@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);
}

View File

@ -30,6 +30,7 @@ import java.util.Map;
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 class MoreLikeThisHandler extends RequestHandlerBase
public DocListAndSet getMoreLikeThis( int id, int start, int rows, List<Query> filters, List<InterestingTerm> 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 ) {

View File

@ -28,6 +28,7 @@ import org.apache.lucene.analysis.util.TokenFilterFactory;
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 @@ public class LukeRequestHandler extends RequestHandlerBase
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 @@ public class LukeRequestHandler extends RequestHandlerBase
/**
* @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 @@ public class LukeRequestHandler extends RequestHandlerBase
return key;
}
private static SimpleOrderedMap<Object> getDocumentFieldsInfo( Document doc, int docId, IndexReader reader,
private static SimpleOrderedMap<Object> getDocumentFieldsInfo( StoredDocument doc, int docId, IndexReader reader,
IndexSchema schema ) throws IOException
{
final CharsRef spare = new CharsRef();
@ -342,13 +343,13 @@ public class LukeRequestHandler extends RequestHandlerBase
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 @@ public class LukeRequestHandler extends RequestHandlerBase
// 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;

View File

@ -18,7 +18,9 @@ package org.apache.solr.handler.component;
*/
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 @@ public class RealTimeGetComponent extends SearchComponent
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 @@ public class RealTimeGetComponent extends SearchComponent
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 @@ public class RealTimeGetComponent extends SearchComponent
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 @@ public class RealTimeGetComponent extends SearchComponent
}
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 @@ public class RealTimeGetComponent extends SearchComponent
List<IndexableField> 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);
}
}

View File

@ -33,7 +33,9 @@ import org.apache.lucene.analysis.TokenFilter;
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 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
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 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
}
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 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
// END: Hack
SolrParams params = req.getParams();
IndexableField[] docFields = doc.getFields(fieldName);
StorableField[] docFields = doc.getFields(fieldName);
List<String> listFields = new ArrayList<String>();
for (IndexableField field : docFields) {
for (StorableField field : docFields) {
listFields.add(field.stringValue());
}
@ -545,7 +547,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
}
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 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
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<String> listFields = new ArrayList<String>();
for (IndexableField field : docFields) {
for (StorableField field : docFields) {
if (field.binaryValue() == null)
listFields.add(field.stringValue());
}

View File

@ -20,7 +20,9 @@ import java.io.*;
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 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
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 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
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 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
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 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
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();

View File

@ -22,7 +22,9 @@ import java.io.Writer;
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 @@ public abstract class TextResponseWriter {
} 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 @@ public abstract class TextResponseWriter {
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 @@ public abstract class TextResponseWriter {
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 @@ public abstract class TextResponseWriter {
Set<String> fnames = fields.getLuceneFieldNames();
for (int i=0; i<sz; i++) {
int id = context.iterator.nextDoc();
Document doc = context.searcher.doc(id, fnames);
StoredDocument doc = context.searcher.doc(id, fnames);
SolrDocument sdoc = toSolrDocument( doc );
if( transformer != null ) {
transformer.transform( sdoc, id);

View File

@ -20,7 +20,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.SortField;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.GeneralField;
import org.apache.solr.util.BCDUtils;
import org.apache.solr.response.TextResponseWriter;
@ -46,13 +46,13 @@ public class BCDIntField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
// Note, this can't return type 'Integer' because BCDStrField and BCDLong extend it
@Override
public Object toObject(IndexableField f) {
public Object toObject(GeneralField f) {
return Integer.valueOf( toExternal(f) );
}
@ -62,7 +62,7 @@ public class BCDIntField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
writer.writeInt(name,toExternal(f));
}
}

View File

@ -17,13 +17,13 @@
package org.apache.solr.schema;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.GeneralField;
/**
*
*/
public class BCDLongField extends BCDIntField {
@Override
public Long toObject(IndexableField f) {
public Long toObject(GeneralField f) {
return Long.valueOf( toExternal(f) );
}
}

View File

@ -17,7 +17,7 @@
package org.apache.solr.schema;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.GeneralField;
/**
*
*/
@ -27,7 +27,7 @@ public class BCDStrField extends BCDIntField {
* is not an integer, it will not survive the base10k conversion!
*/
@Override
public String toObject(IndexableField f) {
public String toObject(GeneralField f) {
return toExternal(f);
}
}

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.BytesRef;
@ -35,7 +36,7 @@ public class BinaryField extends FieldType {
}
@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, toBase64String(toObject(f)), false);
}
@ -46,12 +47,12 @@ public class BinaryField extends FieldType {
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return toBase64String(toObject(f));
}
@Override
public ByteBuffer toObject(IndexableField f) {
public ByteBuffer toObject(GeneralField f) {
BytesRef bytes = f.binaryValue();
return ByteBuffer.wrap(bytes.bytes, bytes.offset, bytes.length);
}

View File

@ -18,7 +18,7 @@
package org.apache.solr.schema;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.BytesRef;
@ -112,12 +112,12 @@ public class BoolField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
@Override
public Boolean toObject(IndexableField f) {
public Boolean toObject(GeneralField f) {
return Boolean.valueOf( toExternal(f) );
}
@ -146,7 +146,7 @@ public class BoolField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
writer.writeBool(name, f.stringValue().charAt(0) == 'T');
}
}

View File

@ -18,6 +18,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.ByteFieldSource;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
@ -65,7 +66,7 @@ public class ByteField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String s = f.stringValue();
// these values may be from a legacy lucene index, which may
@ -90,7 +91,7 @@ public class ByteField extends PrimitiveFieldType {
}
@Override
public Byte toObject(IndexableField f) {
public Byte toObject(GeneralField f) {
return Byte.valueOf(toExternal(f));
}
}

View File

@ -31,6 +31,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.collation.CollationKeyAnalyzer;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
@ -185,7 +186,7 @@ public class CollationField extends FieldType {
}
@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);
}

View File

@ -17,6 +17,7 @@ package org.apache.solr.schema;
*/
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
@ -242,7 +243,7 @@ public class CurrencyField extends FieldType implements SchemaAware, ResourceLoa
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField field) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField field) throws IOException {
writer.writeStr(name, field.stringValue(), false);
}

View File

@ -18,6 +18,7 @@
package org.apache.solr.schema;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.docvalues.DocTermsIndexDocValues;
import org.apache.lucene.search.Query;
@ -213,7 +214,7 @@ public class DateField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
@ -222,7 +223,7 @@ public class DateField extends PrimitiveFieldType {
}
@Override
public Date toObject(IndexableField f) {
public Date toObject(GeneralField f) {
try {
return parseDate( toExternal(f) );
}
@ -237,7 +238,7 @@ public class DateField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
writer.writeDate(name, toExternal(f));
}
@ -444,6 +445,10 @@ public class DateField extends PrimitiveFieldType {
minInclusive, maxInclusive);
}
public String storedToIndexed(GeneralField f) {
return null;
}
}

View File

@ -19,6 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.DoubleFieldSource;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
import org.apache.solr.response.TextResponseWriter;
@ -62,7 +63,7 @@ public class DoubleField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String s = f.stringValue();
// these values may be from a legacy lucene index, which may
@ -88,7 +89,7 @@ public class DoubleField extends PrimitiveFieldType {
@Override
public Double toObject(IndexableField f) {
public Double toObject(GeneralField f) {
return Double.valueOf(toExternal(f));
}
}

View File

@ -18,6 +18,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.SortField;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.search.function.FileFloatSource;
import org.apache.solr.search.QParser;
@ -81,7 +82,7 @@ public class ExternalFileField extends FieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
throw new UnsupportedOperationException();
}

View File

@ -23,7 +23,9 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.Query;
@ -319,7 +321,7 @@ public abstract class FieldType extends FieldProperties {
* value
* @see #toInternal
*/
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
// currently used in writing XML of the search result (but perhaps
// a more efficient toXML(IndexableField f, Writer w) should be used
// in the future.
@ -331,7 +333,7 @@ public abstract class FieldType extends FieldProperties {
* @see #toInternal
* @since solr 1.3
*/
public Object toObject(IndexableField f) {
public Object toObject(GeneralField f) {
return toExternal(f); // by default use the string
}
@ -359,7 +361,7 @@ public abstract class FieldType extends FieldProperties {
}
/** Given the stored field, return the indexed form */
public String storedToIndexed(IndexableField f) {
public String storedToIndexed(GeneralField f) {
// right now, the transformation of single valued fields like SortableInt
// is done when the Field is created, not at analysis time... this means
// that the indexed form is the same as the stored field form.
@ -528,7 +530,7 @@ public abstract class FieldType extends FieldProperties {
/**
* calls back to TextResponseWriter to write the field value
*/
public abstract void write(TextResponseWriter writer, String name, IndexableField f) throws IOException;
public abstract void write(TextResponseWriter writer, String name, GeneralField f) throws IOException;
/**

View File

@ -21,6 +21,7 @@ import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.FloatFieldSource;
import org.apache.lucene.search.SortField;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.response.TextResponseWriter;
@ -60,7 +61,7 @@ public class FloatField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String s = f.stringValue();
// these values may be from a legacy lucene index, which may
@ -85,7 +86,7 @@ public class FloatField extends PrimitiveFieldType {
}
@Override
public Float toObject(IndexableField f) {
public Float toObject(GeneralField f) {
return Float.valueOf( toExternal(f) );
}
}

View File

@ -19,6 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.LiteralValueSource;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
@ -73,14 +74,14 @@ public class GeoHashField extends FieldType implements SpatialQueryable {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f)
public void write(TextResponseWriter writer, String name, GeneralField f)
throws IOException {
writer.writeStr(name, toExternal(f), false);
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
Point p = GeohashUtils.decode(f.stringValue(),ctx);
return p.getY() + "," + p.getX();
}

View File

@ -20,9 +20,11 @@ package org.apache.solr.schema;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.AnalyzerWrapper;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.Version;
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.lucene.document.StoredDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.util.DOMUtil;
@ -257,8 +259,8 @@ public final class IndexSchema {
* the specified Document
* @return null if this schema has no unique key field
*/
public String printableUniqueKey(org.apache.lucene.document.Document doc) {
IndexableField f = doc.getField(uniqueKeyFieldName);
public String printableUniqueKey(StoredDocument doc) {
StorableField f = doc.getField(uniqueKeyFieldName);
return f==null ? null : uniqueKeyFieldType.toExternal(f);
}

View File

@ -21,6 +21,7 @@ import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.IntFieldSource;
import org.apache.lucene.search.SortField;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.response.TextResponseWriter;
@ -60,7 +61,7 @@ public class IntField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String s = f.stringValue();
// these values may be from a legacy lucene index, which may
@ -85,7 +86,7 @@ public class IntField extends PrimitiveFieldType {
}
@Override
public Integer toObject(IndexableField f) {
public Integer toObject(GeneralField f) {
return Integer.valueOf( toExternal(f) );
}
}

View File

@ -17,6 +17,7 @@ package org.apache.solr.schema;
*/
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.AtomicReaderContext;
@ -244,7 +245,7 @@ public class LatLonType extends AbstractSubTypeFieldType implements SpatialQuery
}
@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(), false);
}

View File

@ -19,6 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
import org.apache.solr.response.TextResponseWriter;
@ -62,7 +63,7 @@ public class LongField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String s = f.stringValue();
// these values may be from a legacy lucene index, which may
@ -87,7 +88,7 @@ public class LongField extends PrimitiveFieldType {
}
@Override
public Long toObject(IndexableField f) {
public Long toObject(GeneralField f) {
return Long.valueOf( toExternal(f) );
}
}

View File

@ -20,6 +20,7 @@ package org.apache.solr.schema;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.VectorValueSource;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
@ -119,7 +120,7 @@ public class PointType extends CoordinateFieldType implements SpatialQueryable {
}
@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(), false);
}

View File

@ -28,6 +28,7 @@ import java.util.Map;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.AttributeSource;
@ -117,7 +118,7 @@ public class PreAnalyzedField extends FieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f)
public void write(TextResponseWriter writer, String name, GeneralField f)
throws IOException {
writer.writeStr(name, f.stringValue(), true);
}

View File

@ -20,6 +20,7 @@ package org.apache.solr.schema;
import java.io.IOException;
import java.util.Map;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.AtomicReaderContext;
@ -97,7 +98,7 @@ public class RandomSortField extends FieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException { }
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException { }
private static FieldComparatorSource randomComparatorSource = new FieldComparatorSource() {

View File

@ -18,6 +18,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.ShortFieldSource;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
@ -67,7 +68,7 @@ public class ShortField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String s = f.stringValue();
// these values may be from a legacy lucene index, which may
@ -92,7 +93,7 @@ public class ShortField extends PrimitiveFieldType {
}
@Override
public Short toObject(IndexableField f) {
public Short toObject(GeneralField f) {
return Short.valueOf(toExternal(f));
}

View File

@ -29,6 +29,7 @@ import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueDouble;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.response.TextResponseWriter;
@ -70,12 +71,12 @@ public class SortableDoubleField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
@Override
public Double toObject(IndexableField f) {
public Double toObject(GeneralField f) {
return NumberUtils.SortableStr2double(f.stringValue());
}
@ -94,7 +95,7 @@ public class SortableDoubleField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String sval = f.stringValue();
writer.writeDouble(name, NumberUtils.SortableStr2double(sval));
}

View File

@ -29,6 +29,7 @@ import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueFloat;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.response.TextResponseWriter;
@ -71,12 +72,12 @@ public class SortableFloatField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
@Override
public Float toObject(IndexableField f) {
public Float toObject(GeneralField f) {
return NumberUtils.SortableStr2float(f.stringValue());
}
@ -94,7 +95,7 @@ public class SortableFloatField extends PrimitiveFieldType {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String sval = f.stringValue();
writer.writeFloat(name, NumberUtils.SortableStr2float(sval));
}

View File

@ -29,6 +29,7 @@ import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueInt;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.response.TextResponseWriter;
@ -74,7 +75,7 @@ public class SortableIntField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
@ -92,12 +93,12 @@ public class SortableIntField extends PrimitiveFieldType {
}
@Override
public Integer toObject(IndexableField f) {
public Integer toObject(GeneralField f) {
return NumberUtils.SortableStr2int(f.stringValue(), 0, 3);
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String sval = f.stringValue();
writer.writeInt(name, NumberUtils.SortableStr2int(sval,0,sval.length()));
}

View File

@ -29,6 +29,7 @@ import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueLong;
import org.apache.solr.search.QParser;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.response.TextResponseWriter;
@ -83,17 +84,17 @@ public class SortableLongField extends PrimitiveFieldType {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return indexedToReadable(f.stringValue());
}
@Override
public Long toObject(IndexableField f) {
public Long toObject(GeneralField f) {
return NumberUtils.SortableStr2long(f.stringValue(),0,5);
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
String sval = f.stringValue();
writer.writeLong(name, NumberUtils.SortableStr2long(sval,0,sval.length()));
}

View File

@ -19,6 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.SortField;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.response.TextResponseWriter;
@ -35,7 +36,7 @@ public class StrField extends PrimitiveFieldType {
}
@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);
}

View File

@ -19,6 +19,7 @@ package org.apache.solr.schema;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.search.*;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.Term;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
@ -98,7 +99,7 @@ public class TextField extends FieldType {
}
@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);
}

View File

@ -20,6 +20,7 @@ package org.apache.solr.schema;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.solr.search.QParser;
import org.apache.solr.response.TextResponseWriter;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.Query;
@ -45,7 +46,7 @@ public class TrieDateField extends DateField {
}
@Override
public Date toObject(IndexableField f) {
public Date toObject(GeneralField f) {
return (Date) wrappedField.toObject(f);
}
@ -73,7 +74,7 @@ public class TrieDateField extends DateField {
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
wrappedField.write(writer, name, f);
}
@ -103,7 +104,7 @@ public class TrieDateField extends DateField {
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return wrappedField.toExternal(f);
}
@ -118,7 +119,7 @@ public class TrieDateField extends DateField {
}
@Override
public String storedToIndexed(IndexableField f) {
public String storedToIndexed(GeneralField f) {
return wrappedField.storedToIndexed(f);
}

View File

@ -29,6 +29,7 @@ import org.apache.lucene.document.FieldType.NumericType;
import org.apache.lucene.document.FloatField;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.LongField;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.DoubleFieldSource;
@ -112,7 +113,7 @@ public class TrieField extends PrimitiveFieldType {
}
@Override
public Object toObject(IndexableField f) {
public Object toObject(GeneralField f) {
final Number val = f.numericValue();
if (val != null) {
return (type == TrieTypes.DATE) ? new Date(val.longValue()) : val;
@ -209,7 +210,7 @@ public class TrieField extends PrimitiveFieldType {
@Override
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
writer.writeVal(name, toObject(f));
}
@ -333,13 +334,13 @@ public class TrieField extends PrimitiveFieldType {
return readableToIndexed(val);
}
static String badFieldString(IndexableField f) {
static String badFieldString(GeneralField f) {
String s = f.stringValue();
return "ERROR:SCHEMA-INDEX-MISMATCH,stringValue="+s;
}
@Override
public String toExternal(IndexableField f) {
public String toExternal(GeneralField f) {
return (type == TrieTypes.DATE)
? dateField.toExternal((Date) toObject(f))
: toObject(f).toString();
@ -411,7 +412,7 @@ public class TrieField extends PrimitiveFieldType {
}
@Override
public String storedToIndexed(IndexableField f) {
public String storedToIndexed(GeneralField f) {
final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
final Number val = f.numericValue();
if (val != null) {

View File

@ -22,6 +22,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.SortField;
import org.apache.solr.common.SolrException;
@ -53,7 +54,7 @@ public class UUIDField extends StrField {
}
@Override
public void write(TextResponseWriter writer, String name, IndexableField f)
public void write(TextResponseWriter writer, String name, GeneralField f)
throws IOException {
writer.writeStr(name, f.stringValue(), false);
}
@ -88,7 +89,7 @@ public class UUIDField extends StrField {
}
@Override
public UUID toObject(IndexableField f) {
public UUID toObject(GeneralField f) {
return UUID.fromString(f.stringValue());
}
}

View File

@ -31,6 +31,7 @@ import org.apache.lucene.document.FloatField;
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 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
private final boolean cachingEnabled;
private final SolrCache<Query,DocSet> filterCache;
private final SolrCache<QueryResultKey,DocList> queryResultCache;
private final SolrCache<Integer,Document> documentCache;
private final SolrCache<Integer,StoredDocument> documentCache;
private final SolrCache<String,UnInvertedField> fieldValueCache;
private final LuceneQueryOptimizer optimizer;
@ -433,7 +434,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
// need to open up access to its Document...
static class SetNonLazyFieldSelector extends StoredFieldVisitor {
private Set<String> fieldsToLoad;
final Document doc = new Document();
final StoredDocument doc = new StoredDocument();
final LazyDocument lazyDoc;
SetNonLazyFieldSelector(Set<String> toLoad, IndexReader reader, int docID) {
@ -502,7 +503,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
* 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<String>)null);
}
@ -522,9 +523,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
* filter is provided, only the provided fields will be loaded (the
* remainder will be available lazily).
*/
public Document doc(int i, Set<String> fields) throws IOException {
public StoredDocument doc(int i, Set<String> fields) throws IOException {
Document d;
StoredDocument d;
if (documentCache != null) {
d = documentCache.get(i);
if (d!=null) return d;
@ -549,14 +550,14 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
* 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<String> fields) throws IOException {
public void readDocs(StoredDocument[] docs, DocList ids, Set<String> fields) throws IOException {
DocIterator iter = ids.iterator();
for (int i=0; i<docs.length; i++) {
docs[i] = doc(iter.nextDoc(), fields);
@ -1893,8 +1894,8 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
* Takes a list of docs (the doc ids actually), and returns an array
* of Documents containing all of the stored fields.
*/
public Document[] readDocs(DocList ids) throws IOException {
Document[] docs = new Document[ids.size()];
public StoredDocument[] readDocs(DocList ids) throws IOException {
StoredDocument[] docs = new StoredDocument[ids.size()];
readDocs(docs,ids);
return docs;
}

View File

@ -19,6 +19,7 @@ package org.apache.solr.search.grouping.distributed.shardresultserializer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Sort;
@ -179,7 +180,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
NamedList<Object> document = new NamedList<Object>();
documents.add(document);
Document doc = retrieveDocument(uniqueField, searchGroup.scoreDocs[i].doc);
StoredDocument doc = retrieveDocument(uniqueField, searchGroup.scoreDocs[i].doc);
document.add("id", uniqueField.getType().toExternal(doc.getField(uniqueField.getName())));
if (!Float.isNaN(searchGroup.scoreDocs[i].score)) {
document.add("score", searchGroup.scoreDocs[i].score);
@ -232,7 +233,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
NamedList<Object> document = new NamedList<Object>();
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 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
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();

View File

@ -18,7 +18,9 @@
package org.apache.solr.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.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
@ -332,7 +334,7 @@ public class SolrPluginUtils {
for (int i=0; i<docs.size(); i++) {
int id = iterator.nextDoc();
Document doc = searcher.doc(id);
StoredDocument doc = searcher.doc(id);
String strid = schema.printableUniqueKey(doc);
explainList.add(strid, searcher.explain(query, id) );
@ -848,10 +850,10 @@ public class SolrPluginUtils {
while (dit.hasNext()) {
int docid = dit.nextDoc();
Document luceneDoc = searcher.doc(docid, fields);
StoredDocument luceneDoc = searcher.doc(docid, fields);
SolrDocument doc = new SolrDocument();
for( IndexableField field : luceneDoc) {
for( StorableField field : luceneDoc) {
if (null == fields || fields.contains(field.name())) {
SchemaField sf = schema.getField( field.name() );
doc.addField( field.name(), sf.getType().toObject( field ) );

View File

@ -30,6 +30,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LogMergePolicy;
@ -615,7 +616,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
DocList dl = ((ResultContext) rsp.getValues().get("response")).docs;
Document d = req.getSearcher().doc(dl.iterator().nextDoc());
StoredDocument d = req.getSearcher().doc(dl.iterator().nextDoc());
// ensure field is not lazy, only works for Non-Numeric fields currently (if you change schema behind test, this may fail)
assertFalse( ((Field) d.getField("test_hlt")).getClass().getSimpleName().equals("LazyField"));
assertFalse( ((Field) d.getField("title")).getClass().getSimpleName().equals("LazyField"));
@ -638,7 +639,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
DocList dl = ((ResultContext) rsp.getValues().get("response")).docs;
DocIterator di = dl.iterator();
Document d = req.getSearcher().doc(di.nextDoc());
StoredDocument d = req.getSearcher().doc(di.nextDoc());
// ensure field is lazy
assertTrue( (d.getField("test_hlt")).getClass().getSimpleName().equals("LazyField"));
assertFalse( (d.getField("title")).getClass().getSimpleName().equals("LazyField"));

View File

@ -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.FieldType;
import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
@ -338,7 +339,7 @@ public class TestStressLucene extends TestRTGBase {
verbose("ERROR: Couldn't find a doc for id", id, "using reader",r);
}
assertTrue(docid >= 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);