mirror of https://github.com/apache/lucene.git
LUCENE-3312: Apply lucene-3312-patch-12a.patch
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1372427 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
148d99cbbc
commit
481c6d952d
|
@ -21,11 +21,11 @@ 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;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
|
|
|
@ -226,7 +226,7 @@ public class DocMaker implements Closeable {
|
|||
|
||||
final DocState ds = getDocState();
|
||||
final Document doc = reuseFields ? ds.doc : new Document();
|
||||
doc.getFields().clear();
|
||||
doc.clear();
|
||||
|
||||
// Set ID_FIELD
|
||||
FieldType ft = new FieldType(valType);
|
||||
|
|
|
@ -19,8 +19,8 @@ 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;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
|
||||
/**
|
||||
* Abstract class for benchmarking highlighting performance
|
||||
|
|
|
@ -28,12 +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.index.StoredDocument;
|
||||
import org.apache.lucene.search.Collector;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.MultiTermQuery;
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
|
|||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||
import org.apache.lucene.benchmark.byTask.feeds.DocMaker;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.IntField;
|
||||
import org.apache.lucene.document.LongField;
|
||||
import org.apache.lucene.document.FloatField;
|
||||
|
@ -68,7 +69,7 @@ public class ReadTokensTask extends PerfTask {
|
|||
|
||||
@Override
|
||||
public int doLogic() throws Exception {
|
||||
List<IndexableField> fields = doc.getFields();
|
||||
List<Field> fields = doc.getFields();
|
||||
Analyzer analyzer = getRunData().getAnalyzer();
|
||||
int tokenCount = 0;
|
||||
for(final IndexableField field : fields) {
|
||||
|
|
|
@ -21,8 +21,8 @@ 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.index.StoredDocument;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.highlight.Highlighter;
|
||||
import org.apache.lucene.search.highlight.QueryScorer;
|
||||
|
|
|
@ -24,8 +24,8 @@ 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;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
|
||||
/**
|
||||
* Search and Traverse and Retrieve docs task using a
|
||||
|
|
|
@ -20,8 +20,8 @@ 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.index.StoredDocument;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter;
|
||||
import org.apache.lucene.search.vectorhighlight.FieldQuery;
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
|
|||
import org.apache.lucene.benchmark.byTask.utils.StreamUtils;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
|
||||
/**
|
||||
* A task which writes documents, one line per document. Each line is in the
|
||||
|
@ -172,7 +173,7 @@ public class WriteLineDocTask extends PerfTask {
|
|||
|
||||
boolean sufficient = !checkSufficientFields;
|
||||
for (int i=0; i<fieldsToWrite.length; i++) {
|
||||
IndexableField f = doc.getField(fieldsToWrite[i]);
|
||||
StorableField f = doc.getField(fieldsToWrite[i]);
|
||||
String text = f == null ? "" : matcher.reset(f.stringValue()).replaceAll(" ").trim();
|
||||
sb.append(text).append(SEP);
|
||||
sufficient |= text.length()>0 && sufficientFields[i];
|
||||
|
|
|
@ -27,8 +27,8 @@ 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 org.apache.lucene.index.StoredDocument;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
package org.apache.lucene.codecs;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.MergeState;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
||||
/**
|
||||
* Copyright 2004 The Apache Software Foundation
|
||||
*
|
||||
|
@ -31,13 +19,13 @@ import org.apache.lucene.util.Bits;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.MergeState;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
|
||||
/**
|
||||
* Codec API for writing stored fields:
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.lucene.codecs.CodecUtil;
|
|||
import org.apache.lucene.codecs.StoredFieldsReader;
|
||||
import org.apache.lucene.codecs.StoredFieldsWriter;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
|
@ -31,6 +30,7 @@ import org.apache.lucene.index.IndexableField;
|
|||
import org.apache.lucene.index.MergeState;
|
||||
import org.apache.lucene.index.SegmentReader;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexDocument;
|
|||
import org.apache.lucene.index.IndexReader; // for javadoc
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.search.IndexSearcher; // for javadoc
|
||||
import org.apache.lucene.search.ScoreDoc; // for javadoc
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -50,6 +51,30 @@ public final class Document implements IndexDocument{
|
|||
/** Constructs a new document with no fields. */
|
||||
public Document() {}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Document from StoredDocument so it that can be used e.g. for another
|
||||
* round of indexing.
|
||||
*
|
||||
* @return a new instance of Document representation of this StoredDocument
|
||||
*/
|
||||
public Document(StoredDocument storedDoc) {
|
||||
for (StorableField field : storedDoc.getFields()) {
|
||||
Field newField = new Field(field.name(), (FieldType) field.fieldType());
|
||||
|
||||
newField.fieldsData = field.stringValue();
|
||||
if (newField.fieldsData == null)
|
||||
newField.fieldsData = field.numericValue();
|
||||
if (newField.fieldsData == null)
|
||||
newField.fieldsData = field.binaryValue();
|
||||
if (newField.fieldsData == null)
|
||||
newField.fieldsData = field.readerValue();
|
||||
|
||||
add(newField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Adds a field to a document. Several fields may be added with
|
||||
* the same name. In this case, if the fields are indexed, their text is
|
||||
|
@ -64,14 +89,6 @@ public final class Document implements IndexDocument{
|
|||
fields.add(field);
|
||||
}
|
||||
|
||||
public final void add(IndexableField field) {
|
||||
fields.add((Field) field);
|
||||
}
|
||||
|
||||
public final void add(StorableField field) {
|
||||
fields.add((Field) field);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Removes field with the specified name from the document.
|
||||
* If multiple fields exist with this name, this method removes the first field that has been added.
|
||||
|
@ -167,8 +184,8 @@ public final class Document implements IndexDocument{
|
|||
* null. If multiple fields exists with this name, this method returns the
|
||||
* first value added.
|
||||
*/
|
||||
public final IndexableField getField(String name) {
|
||||
for (IndexableField field : fields) {
|
||||
public final Field getField(String name) {
|
||||
for (Field field : fields) {
|
||||
if (field.name().equals(name)) {
|
||||
return field;
|
||||
}
|
||||
|
@ -184,15 +201,15 @@ public final class Document implements IndexDocument{
|
|||
* @param name the name of the field
|
||||
* @return a <code>Fieldable[]</code> array
|
||||
*/
|
||||
public IndexableField[] getFields(String name) {
|
||||
List<IndexableField> result = new ArrayList<IndexableField>();
|
||||
for (IndexableField field : fields) {
|
||||
public Field[] getFields(String name) {
|
||||
List<Field> result = new ArrayList<Field>();
|
||||
for (Field field : fields) {
|
||||
if (field.name().equals(name)) {
|
||||
result.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new IndexableField[result.size()]);
|
||||
return result.toArray(new Field[result.size()]);
|
||||
}
|
||||
|
||||
/** Returns a List of all the fields in a document.
|
||||
|
@ -200,14 +217,11 @@ public final class Document implements IndexDocument{
|
|||
* <i>not</i> available in documents retrieved from the
|
||||
* index, e.g. {@link IndexSearcher#doc(int)} or {@link
|
||||
* IndexReader#document(int)}.
|
||||
*
|
||||
* @return an immutable <code>List[Field]</code>
|
||||
*/
|
||||
public final List<IndexableField> getFields() {
|
||||
List<IndexableField> result = new ArrayList<IndexableField>();
|
||||
for (IndexableField field : fields) {
|
||||
result.add(field);
|
||||
}
|
||||
|
||||
return result;
|
||||
public final List<Field> getFields() {
|
||||
return Collections.unmodifiableList(fields);
|
||||
}
|
||||
|
||||
private final static String[] NO_STRINGS = new String[0];
|
||||
|
@ -275,6 +289,7 @@ public final class Document implements IndexDocument{
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
/** Obtains all indexed fields in document */
|
||||
@Override
|
||||
public Iterable<? extends IndexableField> indexableFields() {
|
||||
Iterator<Field> it = indexedFieldsIterator();
|
||||
|
@ -287,6 +302,8 @@ public final class Document implements IndexDocument{
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** Obtains all stored fields in document. */
|
||||
@Override
|
||||
public Iterable<? extends StorableField> storableFields() {
|
||||
Iterator<Field> it = storedFieldsIterator();
|
||||
|
@ -299,7 +316,7 @@ public final class Document implements IndexDocument{
|
|||
return result;
|
||||
}
|
||||
|
||||
public Iterator<Field> storedFieldsIterator() {
|
||||
private Iterator<Field> storedFieldsIterator() {
|
||||
return new FilterIterator<Field>(fields.iterator()) {
|
||||
@Override
|
||||
protected boolean predicateFunction(Field field) {
|
||||
|
@ -308,7 +325,7 @@ public final class Document implements IndexDocument{
|
|||
};
|
||||
}
|
||||
|
||||
public Iterator<Field> indexedFieldsIterator() {
|
||||
private Iterator<Field> indexedFieldsIterator() {
|
||||
return new FilterIterator<Field>(fields.iterator()) {
|
||||
@Override
|
||||
protected boolean predicateFunction(Field field) {
|
||||
|
@ -316,4 +333,9 @@ public final class Document implements IndexDocument{
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Removes all the fields from document. */
|
||||
public void clear() {
|
||||
fields.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.HashSet;
|
|||
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.StoredFieldVisitor;
|
||||
|
||||
/** A {@link StoredFieldVisitor} that creates a {@link
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.apache.lucene.document;
|
||||
|
||||
import org.apache.lucene.index.IndexReader; // javadocs
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.search.IndexSearcher; // javadocs
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.lucene.codecs.BlockTreeTermsReader;
|
|||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.FieldType; // for javadocs
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.DocValues.SortedSource;
|
||||
import org.apache.lucene.index.DocValues.Source;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package org.apache.lucene.index;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -29,16 +25,4 @@ public interface GeneralField {
|
|||
/** {@link IndexableFieldType} describing the properties
|
||||
* of this field. */
|
||||
public IndexableFieldType fieldType();
|
||||
|
||||
/** Non-null if this field has a binary value */
|
||||
public BytesRef binaryValue();
|
||||
|
||||
/** Non-null if this field has a string value */
|
||||
public String stringValue();
|
||||
|
||||
/** Non-null if this field has a Reader value */
|
||||
public Reader readerValue();
|
||||
|
||||
/** Non-null if this field has a numeric value */
|
||||
public Number numericValue();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@ package org.apache.lucene.index;
|
|||
* @lucene.internal
|
||||
*/
|
||||
public interface IndexDocument {
|
||||
|
||||
/** Obtains all indexable fields in document */
|
||||
public Iterable<? extends IndexableField> indexableFields();
|
||||
|
||||
/** Obtains all storable fields in document */
|
||||
public Iterable<? extends StorableField> storableFields();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.DocumentStoredFieldVisitor;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.search.SearcherManager; // javadocs
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.lucene.search.similarities.Similarity;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
* Stores the normalization value computed in
|
||||
* Stores the normalization value with {@link StorableField} computed in
|
||||
* {@link Similarity#computeNorm(FieldInvertState, Norm)} per field.
|
||||
* Normalization values must be consistent within a single field, different
|
||||
* value types are not permitted within a single field. All values set must be
|
||||
|
@ -48,9 +48,9 @@ public final class Norm {
|
|||
private BytesRef spare;
|
||||
|
||||
/**
|
||||
* Returns the {@link IndexableField} representation for this norm
|
||||
* Returns the {@link StorableField} representation for this norm
|
||||
*/
|
||||
public StoredField field() {
|
||||
public StorableField field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map.Entry;
|
|||
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.document.StoredField;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
@ -73,9 +72,9 @@ public class PersistentSnapshotDeletionPolicy extends SnapshotDeletionPolicy {
|
|||
if (doc.getField(SNAPSHOTS_ID) == null) {
|
||||
throw new IllegalStateException("directory is not a valid snapshots store!");
|
||||
}
|
||||
doc.removeField(SNAPSHOTS_ID);
|
||||
for (StorableField f : doc) {
|
||||
snapshots.put(f.name(), f.stringValue());
|
||||
if (!f.name().equals(SNAPSHOTS_ID))
|
||||
snapshots.put(f.name(), f.stringValue());
|
||||
}
|
||||
} else if (numDocs != 0) {
|
||||
throw new IllegalStateException(
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package org.apache.lucene.index;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -22,6 +17,21 @@ import org.apache.lucene.util.BytesRef;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
public interface StorableField extends GeneralField {
|
||||
|
||||
|
||||
/** Non-null if this field has a binary value */
|
||||
public BytesRef binaryValue();
|
||||
|
||||
/** Non-null if this field has a string value */
|
||||
public String stringValue();
|
||||
|
||||
/** Non-null if this field has a Reader value */
|
||||
public Reader readerValue();
|
||||
|
||||
/** Non-null if this field has a numeric value */
|
||||
public Number numericValue();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
package org.apache.lucene.document;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
package org.apache.lucene.index;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -25,6 +17,21 @@ import org.apache.lucene.util.BytesRef;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.DoubleField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.FloatField;
|
||||
import org.apache.lucene.document.IntField;
|
||||
import org.apache.lucene.document.LongField;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
public class StoredDocument implements Iterable<StorableField>{
|
||||
|
||||
private final List<StorableField> fields = new ArrayList<StorableField>();
|
||||
|
@ -45,6 +52,10 @@ public class StoredDocument implements Iterable<StorableField>{
|
|||
return result.toArray(new StorableField[result.size()]);
|
||||
}
|
||||
|
||||
/** Returns a field with the given name if any exist in this document, or
|
||||
* null. If multiple fields exists with this name, this method returns the
|
||||
* first value added.
|
||||
*/
|
||||
public final StorableField getField(String name) {
|
||||
for (StorableField field : fields) {
|
||||
if (field.name().equals(name)) {
|
||||
|
@ -54,36 +65,15 @@ public class StoredDocument implements Iterable<StorableField>{
|
|||
return null;
|
||||
}
|
||||
|
||||
public final void removeField(String name) {
|
||||
Iterator<StorableField> it = fields.iterator();
|
||||
while (it.hasNext()) {
|
||||
StorableField field = it.next();
|
||||
if (field.name().equals(name)) {
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Removes all fields with the given name from the document.
|
||||
* If there is no field with the specified name, the document remains unchanged.</p>
|
||||
* <p> Note that the removeField(s) methods like the add method only make sense
|
||||
* prior to adding a document to an index. These methods cannot
|
||||
* be used to change the content of an existing index! In order to achieve this,
|
||||
* a document has to be deleted from an index and a new changed version of that
|
||||
* document has to be added.</p>
|
||||
|
||||
/** Returns a List of all the fields in a document.
|
||||
* <p>Note that fields which are <i>not</i> stored are
|
||||
* <i>not</i> available in documents retrieved from the
|
||||
* index, e.g. {@link IndexSearcher#doc(int)} or {@link
|
||||
* IndexReader#document(int)}.
|
||||
*
|
||||
* @return an immutable <code>List[StorableField]</code>
|
||||
*/
|
||||
public final void removeFields(String name) {
|
||||
Iterator<StorableField> it = fields.iterator();
|
||||
while (it.hasNext()) {
|
||||
StorableField field = it.next();
|
||||
if (field.name().equals(name)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final List<StorableField> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
@ -180,26 +170,6 @@ public class StoredDocument implements Iterable<StorableField>{
|
|||
return null;
|
||||
}
|
||||
|
||||
public Document asIndexable() {
|
||||
Document doc = new Document();
|
||||
|
||||
for (StorableField field : fields) {
|
||||
Field newField = new Field(field.name(), (FieldType) field.fieldType());
|
||||
|
||||
newField.fieldsData = field.stringValue();
|
||||
if (newField.fieldsData == null)
|
||||
newField.fieldsData = field.numericValue();
|
||||
if (newField.fieldsData == null)
|
||||
newField.fieldsData = field.binaryValue();
|
||||
if (newField.fieldsData == null)
|
||||
newField.fieldsData = field.readerValue();
|
||||
|
||||
doc.add(newField);
|
||||
}
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
/** Prints the fields of a document for human consumption. */
|
||||
@Override
|
||||
public final String toString() {
|
|
@ -33,13 +33,13 @@ import java.util.concurrent.locks.Lock;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.DirectoryReader; // javadocs
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.MultiFields;
|
||||
import org.apache.lucene.index.IndexReaderContext;
|
||||
import org.apache.lucene.index.ReaderUtil;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.StoredFieldVisitor;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermContext;
|
||||
|
|
|
@ -23,9 +23,9 @@ 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.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.search.*;
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.lucene.analysis.MockAnalyzer;
|
|||
import org.apache.lucene.codecs.appending.AppendingCodec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.DocsEnum;
|
||||
|
@ -33,6 +32,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.MultiFields;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum.SeekStatus;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.apache.lucene.document;
|
|||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.document;
|
|||
*/
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.analysis.EmptyTokenizer;
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
|
@ -27,6 +28,8 @@ import org.apache.lucene.index.IndexWriter;
|
|||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -124,7 +127,7 @@ public class TestDocument extends LuceneTestCase {
|
|||
// siltenlty ignored
|
||||
assertEquals(0, doc.getFields().size());
|
||||
}
|
||||
|
||||
|
||||
public void testConstructorExceptions() {
|
||||
FieldType ft = new FieldType();
|
||||
ft.setStored(true);
|
||||
|
@ -147,6 +150,34 @@ public class TestDocument extends LuceneTestCase {
|
|||
// expected exception
|
||||
}
|
||||
}
|
||||
|
||||
public void testClearDocument() {
|
||||
Document doc = makeDocumentWithFields();
|
||||
assertEquals(8, doc.getFields().size());
|
||||
doc.clear();
|
||||
assertEquals(0, doc.getFields().size());
|
||||
}
|
||||
|
||||
public void testGetFieldsImmutable() {
|
||||
Document doc = makeDocumentWithFields();
|
||||
assertEquals(8, doc.getFields().size());
|
||||
List<Field> fields = doc.getFields();
|
||||
try {
|
||||
fields.add( new StringField("name", "value", Field.Store.NO) );
|
||||
fail("Document.getFields() should return immutable List");
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
// OK
|
||||
}
|
||||
|
||||
try {
|
||||
fields.clear();
|
||||
fail("Document.getFields() should return immutable List");
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
// OK
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link Document#getValues(String)} method for a brand new Document
|
||||
|
@ -215,13 +246,13 @@ public class TestDocument extends LuceneTestCase {
|
|||
}
|
||||
|
||||
private void doAssert(StoredDocument doc) {
|
||||
doAssert(doc.asIndexable(), true);
|
||||
doAssert(new Document(doc), true);
|
||||
}
|
||||
private void doAssert(Document doc, boolean fromIndex) {
|
||||
IndexableField[] keywordFieldValues = doc.getFields("keyword");
|
||||
IndexableField[] textFieldValues = doc.getFields("text");
|
||||
IndexableField[] unindexedFieldValues = doc.getFields("unindexed");
|
||||
IndexableField[] unstoredFieldValues = doc.getFields("unstored");
|
||||
StorableField[] keywordFieldValues = doc.getFields("keyword");
|
||||
StorableField[] textFieldValues = doc.getFields("text");
|
||||
StorableField[] unindexedFieldValues = doc.getFields("unindexed");
|
||||
StorableField[] unstoredFieldValues = doc.getFields("unstored");
|
||||
|
||||
assertTrue(keywordFieldValues.length == 2);
|
||||
assertTrue(textFieldValues.length == 2);
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat;
|
|||
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.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.apache.lucene.document.LongField;
|
|||
import org.apache.lucene.document.PackedLongDocValuesField;
|
||||
import org.apache.lucene.document.ShortDocValuesField;
|
||||
import org.apache.lucene.document.SortedBytesDocValuesField;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.document.StraightBytesDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Random;
|
|||
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.document.TextField;
|
||||
import org.apache.lucene.index.DocValues.Source;
|
||||
import org.apache.lucene.index.DocValues.Type;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
|
|||
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.document.StoredField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
|
|
@ -32,7 +32,6 @@ 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.document.TextField;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.document.ByteDocValuesField;
|
|||
import org.apache.lucene.document.DerefBytesDocValuesField;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.DoubleDocValuesField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FloatDocValuesField;
|
||||
import org.apache.lucene.document.IntDocValuesField;
|
||||
import org.apache.lucene.document.LongDocValuesField;
|
||||
|
@ -67,7 +68,7 @@ public class TestDocValuesTypeCompatibility extends LuceneTestCase {
|
|||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
public IndexableField getRandomIntsField(Type maxType, boolean force) {
|
||||
public Field getRandomIntsField(Type maxType, boolean force) {
|
||||
switch (maxType) {
|
||||
|
||||
case VAR_INTS:
|
||||
|
@ -120,7 +121,7 @@ public class TestDocValuesTypeCompatibility extends LuceneTestCase {
|
|||
|
||||
}
|
||||
@SuppressWarnings("fallthrough")
|
||||
public IndexableField getRandomFloatField(Type maxType, boolean force) {
|
||||
public Field getRandomFloatField(Type maxType, boolean force) {
|
||||
switch (maxType) {
|
||||
|
||||
case FLOAT_64:
|
||||
|
@ -161,7 +162,7 @@ public class TestDocValuesTypeCompatibility extends LuceneTestCase {
|
|||
iwc.setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH);
|
||||
iwc.setRAMPerThreadHardLimitMB(2000);
|
||||
IndexWriter writer = new IndexWriter(dir, iwc);
|
||||
IndexableField[] fields = new IndexableField[] {
|
||||
Field[] fields = new Field[] {
|
||||
new DoubleDocValuesField("f", 1.0), new IntDocValuesField("f", 1),
|
||||
new ShortDocValuesField("f", (short) 1),
|
||||
new ByteDocValuesField("f", (byte) 1)};
|
||||
|
@ -194,7 +195,7 @@ public class TestDocValuesTypeCompatibility extends LuceneTestCase {
|
|||
IndexWriter writer = new IndexWriter(dir, iwc);
|
||||
boolean mustBeFixed = random().nextBoolean();
|
||||
int maxSize = 2 + random().nextInt(15);
|
||||
IndexableField bytesField = getRandomBytesField(mustBeFixed, maxSize,
|
||||
Field bytesField = getRandomBytesField(mustBeFixed, maxSize,
|
||||
true);
|
||||
addDoc(writer, bytesField);
|
||||
for (int j = 0; j < numDocs; j++) {
|
||||
|
@ -207,7 +208,7 @@ public class TestDocValuesTypeCompatibility extends LuceneTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public IndexableField getRandomBytesField(boolean mustBeFixed, int maxSize,
|
||||
public Field getRandomBytesField(boolean mustBeFixed, int maxSize,
|
||||
boolean mustBeVariableIfNotFixed) {
|
||||
int size = mustBeFixed ? maxSize : random().nextInt(maxSize) + 1;
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
@ -256,16 +257,16 @@ public class TestDocValuesTypeCompatibility extends LuceneTestCase {
|
|||
dir.close();
|
||||
}
|
||||
|
||||
private void addDoc(IndexWriter writer, IndexableField... fields)
|
||||
private void addDoc(IndexWriter writer, Field... fields)
|
||||
throws IOException {
|
||||
Document doc = new Document();
|
||||
for (IndexableField indexableField : fields) {
|
||||
for (Field indexableField : fields) {
|
||||
doc.add(indexableField);
|
||||
}
|
||||
writer.addDocument(doc);
|
||||
}
|
||||
|
||||
public IndexableField getRandomIndexableDVField() {
|
||||
public Field getRandomIndexableDVField() {
|
||||
int size = random().nextInt(100) + 1;
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
|
|||
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.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.lucene.analysis.Analyzer;
|
|||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.TermsEnum.SeekStatus;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.lucene.document.FieldType;
|
|||
import org.apache.lucene.document.FloatField;
|
||||
import org.apache.lucene.document.IntField;
|
||||
import org.apache.lucene.document.LongField;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.document.StoredField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
|
|||
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.document.StoredField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
|
|
@ -1556,50 +1556,46 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||
try {
|
||||
doc = new Document();
|
||||
// try to boost with norms omitted
|
||||
List<IndexableField> list = new ArrayList<IndexableField>();
|
||||
list.add(new IndexableField() {
|
||||
|
||||
IndexDocument docList = new IndexDocument() {
|
||||
|
||||
List<IndexableField> list = new ArrayList<IndexableField>();
|
||||
List<StorableField> storedList = new ArrayList<StorableField>();
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "foo";
|
||||
public Iterable<? extends IndexableField> indexableFields() {
|
||||
if (list.size() == 0) {
|
||||
list.add(new IndexableField() {
|
||||
@Override
|
||||
public String name() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexableFieldType fieldType() {
|
||||
return StringField.TYPE_NOT_STORED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float boost() {
|
||||
return 5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(Analyzer analyzer) throws IOException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexableFieldType fieldType() {
|
||||
return StringField.TYPE_NOT_STORED;
|
||||
public Iterable<? extends StorableField> storableFields() {
|
||||
return storedList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float boost() {
|
||||
return 5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytesRef binaryValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stringValue() {
|
||||
return "baz";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader readerValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number numericValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(Analyzer analyzer) throws IOException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
iw.addDocument(list);
|
||||
|
||||
};
|
||||
iw.addDocument(docList);
|
||||
fail("didn't get any exception, boost silently discarded");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
// expected
|
||||
|
|
|
@ -21,7 +21,6 @@ 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.document.TextField;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
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.document.TextField;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -142,10 +141,10 @@ public class TestIndexWriterReader extends LuceneTestCase {
|
|||
|
||||
String id10 = r1.document(10).getField("id").stringValue();
|
||||
|
||||
StoredDocument newDoc = r1.document(10);
|
||||
Document newDoc = new Document(r1.document(10));
|
||||
newDoc.removeField("id");
|
||||
newDoc.add(newStringField("id", Integer.toString(8000), Field.Store.YES));
|
||||
writer.updateDocument(new Term("id", id10), newDoc.asIndexable());
|
||||
writer.updateDocument(new Term("id", id10), newDoc);
|
||||
assertFalse(r1.isCurrent());
|
||||
|
||||
DirectoryReader r2 = writer.getReader();
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Set;
|
|||
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.CharsRef;
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Iterator;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.DocValues.Type;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Random;
|
|||
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.document.TextField;
|
||||
import org.apache.lucene.index.DocValues.Source;
|
||||
import org.apache.lucene.index.DocValues.Type;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Random;
|
|||
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.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Random;
|
|||
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.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
|
|
@ -29,7 +29,6 @@ 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.document.TextField;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TestRollingUpdates extends LuceneTestCase {
|
|||
if (VERBOSE) {
|
||||
System.out.println(" docIter=" + docIter + " id=" + id);
|
||||
}
|
||||
((Field) doc.getField("docid")).setStringValue(myID);
|
||||
doc.getField("docid").setStringValue(myID);
|
||||
|
||||
Term idTerm = new Term("docid", myID);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
|
|||
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.document.TextField;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
|
@ -251,7 +250,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
|
|||
Iterator<Document> iter = docs.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Document d = iter.next();
|
||||
ArrayList<IndexableField> fields = new ArrayList<IndexableField>();
|
||||
ArrayList<Field> fields = new ArrayList<Field>();
|
||||
fields.addAll(d.getFields());
|
||||
// put fields in same order each time
|
||||
Collections.sort(fields, fieldNameComparator);
|
||||
|
|
|
@ -30,7 +30,6 @@ 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.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.ScoreDoc;
|
||||
|
|
|
@ -18,11 +18,11 @@ package org.apache.lucene.search;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.junit.AfterClass;
|
||||
|
|
|
@ -25,9 +25,9 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.apache.lucene.document.DateTools;
|
||||
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.StoredDocument;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
|
@ -30,6 +29,7 @@ import org.apache.lucene.index.Norm;
|
|||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.lucene.index.FieldInvertState;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||
import org.apache.lucene.search.similarities.Similarity;
|
||||
|
|
|
@ -23,13 +23,13 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.FloatField;
|
||||
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;
|
||||
import org.apache.lucene.index.MultiFields;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
|
|
@ -23,13 +23,13 @@ import org.apache.lucene.document.DoubleField;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.LongField;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.MultiFields;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TestPhraseQuery extends LuceneTestCase {
|
|||
Document doc = new Document();
|
||||
doc.add(newTextField("field", "one two three four five", Field.Store.YES));
|
||||
doc.add(newTextField("repeated", "this is a repeated field - first part", Field.Store.YES));
|
||||
IndexableField repeatedField = newTextField("repeated", "second part of a repeated field", Field.Store.YES);
|
||||
Field repeatedField = newTextField("repeated", "second part of a repeated field", Field.Store.YES);
|
||||
doc.add(repeatedField);
|
||||
doc.add(newTextField("palindrome", "one two three two one", Field.Store.YES));
|
||||
writer.addDocument(doc);
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.lucene.document.FieldType;
|
|||
import org.apache.lucene.document.FloatDocValuesField;
|
||||
import org.apache.lucene.document.PackedLongDocValuesField;
|
||||
import org.apache.lucene.document.SortedBytesDocValuesField;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.document.StraightBytesDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
@ -52,6 +51,7 @@ import org.apache.lucene.index.IndexableField;
|
|||
import org.apache.lucene.index.MultiReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.FieldValueHitQueue.Entry;
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.lucene.search.spans;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
|
@ -29,6 +28,7 @@ import org.apache.lucene.analysis.MockTokenizer;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.StoredDocument;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
|
@ -30,6 +29,7 @@ import org.apache.lucene.index.DirectoryReader;
|
|||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.util.English;
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.util.Date;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
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.StoredDocument;
|
||||
import org.apache.lucene.queryparser.classic.QueryParser;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
|
|
@ -36,12 +36,12 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
|||
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.document.TextField;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.queryparser.xml.CorePlusExtensionsParser;
|
||||
import org.apache.lucene.queryparser.xml.QueryTemplateManager;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
|
|
@ -594,7 +594,7 @@ public class TestGrouping extends LuceneTestCase {
|
|||
Document doc = new Document();
|
||||
docs.add(doc);
|
||||
if (groupValue.group != null) {
|
||||
doc.add(newStringField("group", groupValue.group.utf8ToString(), Field.Store.NO));
|
||||
doc.add(newStringField("group", groupValue.group.utf8ToString(), Field.Store.YES));
|
||||
}
|
||||
doc.add(newStringField("sort1", groupValue.sort1.utf8ToString(), Field.Store.NO));
|
||||
doc.add(newStringField("sort2", groupValue.sort2.utf8ToString(), Field.Store.NO));
|
||||
|
|
|
@ -32,10 +32,10 @@ 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;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
|
|
|
@ -37,12 +37,12 @@ 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;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.Term;
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.lucene.index.FieldInfo;
|
|||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexableFieldType;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/** Defers actually loading a field's value until you ask
|
||||
|
|
|
@ -19,7 +19,6 @@ 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;
|
||||
|
|
|
@ -22,12 +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.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
|
|
|
@ -23,10 +23,10 @@ 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;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.queryparser.classic.QueryParser;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
|
|
@ -24,11 +24,11 @@ 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;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
|
|
@ -23,7 +23,6 @@ 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;
|
||||
|
|
|
@ -21,9 +21,9 @@ 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.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.lucene.spatial;
|
|||
|
||||
import com.spatial4j.core.context.SpatialContext;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.queries.function.FunctionQuery;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
@ -97,7 +99,7 @@ public abstract class SpatialStrategy {
|
|||
*
|
||||
* @return Not null nor will it have null elements.
|
||||
*/
|
||||
public abstract IndexableField[] createIndexableFields(Shape shape);
|
||||
public abstract Field[] createIndexableFields(Shape shape);
|
||||
|
||||
/**
|
||||
* The value source yields a number that is proportional to the distance between the query shape and indexed data.
|
||||
|
|
|
@ -92,11 +92,11 @@ public class BBoxStrategy extends SpatialStrategy {
|
|||
//---------------------------------
|
||||
|
||||
@Override
|
||||
public IndexableField[] createIndexableFields(Shape shape) {
|
||||
public Field[] createIndexableFields(Shape shape) {
|
||||
Rectangle bbox = shape.getBoundingBox();
|
||||
FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);
|
||||
doubleFieldType.setNumericPrecisionStep(precisionStep);
|
||||
IndexableField[] fields = new IndexableField[5];
|
||||
Field[] fields = new Field[5];
|
||||
fields[0] = new DoubleField(field_minX, bbox.getMinX(), doubleFieldType);
|
||||
fields[1] = new DoubleField(field_maxX, bbox.getMaxX(), doubleFieldType);
|
||||
fields[2] = new DoubleField(field_minY, bbox.getMinY(), doubleFieldType);
|
||||
|
|
|
@ -63,7 +63,7 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IndexableField[] createIndexableFields(Shape shape) {
|
||||
public Field[] createIndexableFields(Shape shape) {
|
||||
int detailLevel = grid.getMaxLevelForPrecision(shape,distErrPct);
|
||||
List<Node> cells = grid.getNodes(shape, detailLevel, true);//true=intermediates cells
|
||||
//If shape isn't a point, add a full-resolution center-point so that
|
||||
|
@ -79,7 +79,7 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {
|
|||
// http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4
|
||||
|
||||
Field field = new Field(getFieldName(), new CellTokenStream(cells.iterator()), FIELD_TYPE);
|
||||
return new IndexableField[]{field};
|
||||
return new Field[]{field};
|
||||
}
|
||||
|
||||
/* Indexed, tokenized, not stored. */
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.spatial4j.core.shape.Point;
|
|||
import com.spatial4j.core.shape.Rectangle;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
import org.apache.lucene.document.DoubleField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.queries.function.FunctionQuery;
|
||||
|
@ -77,12 +78,12 @@ public class TwoDoublesStrategy extends SpatialStrategy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IndexableField[] createIndexableFields(Shape shape) {
|
||||
public Field[] createIndexableFields(Shape shape) {
|
||||
if( shape instanceof Point ) {
|
||||
Point point = (Point)shape;
|
||||
FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);
|
||||
doubleFieldType.setNumericPrecisionStep(precisionStep);
|
||||
IndexableField[] f = new IndexableField[2];
|
||||
Field[] f = new Field[2];
|
||||
f[0] = new DoubleField(fieldNameX, point.getX(), doubleFieldType);
|
||||
f[1] = new DoubleField(fieldNameY, point.getY(), doubleFieldType);
|
||||
return f;
|
||||
|
@ -90,7 +91,7 @@ public class TwoDoublesStrategy extends SpatialStrategy {
|
|||
if( !ignoreIncompatibleGeometry ) {
|
||||
throw new IllegalArgumentException( "TwoDoublesStrategy can not index: "+shape );
|
||||
}
|
||||
return new IndexableField[0]; // nothing (solr does not support null)
|
||||
return new Field[0]; // nothing (solr does not support null)
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -194,7 +194,7 @@ public class PortedSolr3Test extends StrategyTestCase {
|
|||
private Document newDoc(String id, Shape shape) {
|
||||
Document doc = new Document();
|
||||
doc.add(new StringField("id", id, Field.Store.YES));
|
||||
for (IndexableField f : strategy.createIndexableFields(shape)) {
|
||||
for (Field f : strategy.createIndexableFields(shape)) {
|
||||
doc.add(f);
|
||||
}
|
||||
if (storeShape)
|
||||
|
|
|
@ -124,7 +124,7 @@ public class SpatialExample extends LuceneTestCase {
|
|||
//Potentially more than one shape in this field is supported by some
|
||||
// strategies; see the javadocs of the SpatialStrategy impl to see.
|
||||
for (Shape shape : shapes) {
|
||||
for (IndexableField f : strategy.createIndexableFields(shape)) {
|
||||
for (Field f : strategy.createIndexableFields(shape)) {
|
||||
doc.add(f);
|
||||
}
|
||||
//store it too; the format is up to you
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
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.index.StoredDocument;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.ScoreDoc;
|
||||
|
|
|
@ -85,7 +85,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
|
|||
document.add(new StringField("id", data.id, Field.Store.YES));
|
||||
document.add(new StringField("name", data.name, Field.Store.YES));
|
||||
Shape shape = ctx.readShape(data.shape);
|
||||
for (IndexableField f : strategy.createIndexableFields(shape)) {
|
||||
for (Field f : strategy.createIndexableFields(shape)) {
|
||||
document.add(f);
|
||||
}
|
||||
if (storeShape)
|
||||
|
|
|
@ -154,7 +154,7 @@ public class TestRecursivePrefixTreeStrategy extends StrategyTestCase {
|
|||
private Document newDoc(String id, Shape shape) {
|
||||
Document doc = new Document();
|
||||
doc.add(new StringField("id", id, Field.Store.YES));
|
||||
for (IndexableField f : strategy.createIndexableFields(shape)) {
|
||||
for (Field f : strategy.createIndexableFields(shape)) {
|
||||
doc.add(f);
|
||||
}
|
||||
if (storeShape)
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {
|
|||
|
||||
Document losAngeles = new Document();
|
||||
losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
|
||||
for (IndexableField field : prefixGridStrategy.createIndexableFields(point)) {
|
||||
for (Field field : prefixGridStrategy.createIndexableFields(point)) {
|
||||
losAngeles.add(field);
|
||||
}
|
||||
losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
|
|||
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.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
|
@ -36,6 +35,7 @@ import org.apache.lucene.index.IndexWriter;
|
|||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.lucene.analysis.MockTokenizer;
|
|||
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.document.StoredField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
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.search.IndexSearcher;
|
||||
import org.apache.lucene.search.PhraseQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
|
|
@ -29,6 +29,7 @@ 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.index.StorableField;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermRangeQuery;
|
||||
|
@ -211,7 +212,7 @@ public class ICUCollationField extends FieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
writer.writeStr(name, f.stringValue(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ 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.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryparser.classic.ParseException;
|
||||
import org.apache.lucene.search.*;
|
||||
|
|
|
@ -28,7 +28,6 @@ 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;
|
||||
|
|
|
@ -18,9 +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.StoredDocument;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
|
@ -298,7 +298,6 @@ public class RealTimeGetComponent extends SearchComponent
|
|||
private static SolrDocument toSolrDoc(SolrInputDocument sdoc, IndexSchema schema) {
|
||||
// TODO: do something more performant than this double conversion
|
||||
Document doc = DocumentBuilder.toDocument(sdoc, schema);
|
||||
List<IndexableField> fields = doc.getFields();
|
||||
|
||||
// copy the stored fields only
|
||||
StoredDocument out = new StoredDocument();
|
||||
|
|
|
@ -33,9 +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.index.StoredDocument;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.highlight.*;
|
||||
import org.apache.lucene.search.vectorhighlight.BoundaryScanner;
|
||||
|
|
|
@ -20,9 +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.index.StoredDocument;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
|
|
|
@ -22,9 +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.index.StoredDocument;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.lucene.queries.function.ValueSource;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.solr.search.QParser;
|
||||
import org.apache.lucene.index.GeneralField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.solr.util.BCDUtils;
|
||||
import org.apache.solr.response.TextResponseWriter;
|
||||
|
||||
|
@ -46,13 +47,13 @@ public class BCDIntField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toExternal(GeneralField f) {
|
||||
public String toExternal(StorableField f) {
|
||||
return indexedToReadable(f.stringValue());
|
||||
}
|
||||
|
||||
// Note, this can't return type 'Integer' because BCDStrField and BCDLong extend it
|
||||
@Override
|
||||
public Object toObject(GeneralField f) {
|
||||
public Object toObject(StorableField f) {
|
||||
return Integer.valueOf( toExternal(f) );
|
||||
}
|
||||
|
||||
|
@ -62,7 +63,7 @@ public class BCDIntField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
writer.writeInt(name,toExternal(f));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.index.GeneralField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class BCDLongField extends BCDIntField {
|
||||
@Override
|
||||
public Long toObject(GeneralField f) {
|
||||
public Long toObject(StorableField f) {
|
||||
return Long.valueOf( toExternal(f) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.index.GeneralField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ public class BCDStrField extends BCDIntField {
|
|||
* is not an integer, it will not survive the base10k conversion!
|
||||
*/
|
||||
@Override
|
||||
public String toObject(GeneralField f) {
|
||||
public String toObject(StorableField f) {
|
||||
return toExternal(f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ 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.index.StorableField;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.solr.common.util.Base64;
|
||||
|
@ -36,7 +37,7 @@ public class BinaryField extends FieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
writer.writeStr(name, toBase64String(toObject(f)), false);
|
||||
}
|
||||
|
||||
|
@ -47,18 +48,18 @@ public class BinaryField extends FieldType {
|
|||
|
||||
|
||||
@Override
|
||||
public String toExternal(GeneralField f) {
|
||||
public String toExternal(StorableField f) {
|
||||
return toBase64String(toObject(f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toObject(GeneralField f) {
|
||||
public ByteBuffer toObject(StorableField f) {
|
||||
BytesRef bytes = f.binaryValue();
|
||||
return ByteBuffer.wrap(bytes.bytes, bytes.offset, bytes.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexableField createField(SchemaField field, Object val, float boost) {
|
||||
public StorableField createField(SchemaField field, Object val, float boost) {
|
||||
if (val == null) return null;
|
||||
if (!field.stored()) {
|
||||
log.trace("Ignoring unstored binary field: " + field);
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.solr.schema;
|
|||
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.GeneralField;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -112,12 +113,12 @@ public class BoolField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toExternal(GeneralField f) {
|
||||
public String toExternal(StorableField f) {
|
||||
return indexedToReadable(f.stringValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean toObject(GeneralField f) {
|
||||
public Boolean toObject(StorableField f) {
|
||||
return Boolean.valueOf( toExternal(f) );
|
||||
}
|
||||
|
||||
|
@ -146,7 +147,7 @@ public class BoolField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
writer.writeBool(name, f.stringValue().charAt(0) == 'T');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ 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.index.StorableField;
|
||||
import org.apache.lucene.search.SortField;
|
||||
|
||||
import org.apache.solr.response.TextResponseWriter;
|
||||
|
@ -66,7 +67,7 @@ public class ByteField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
String s = f.stringValue();
|
||||
|
||||
// these values may be from a legacy lucene index, which may
|
||||
|
@ -91,7 +92,7 @@ public class ByteField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Byte toObject(GeneralField f) {
|
||||
public Byte toObject(StorableField f) {
|
||||
return Byte.valueOf(toExternal(f));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ 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.index.StorableField;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermRangeQuery;
|
||||
|
@ -186,7 +187,7 @@ public class CollationField extends FieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
writer.writeStr(name, f.stringValue(), true);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue