From 3fa3cf549345dc46f3c891693c4017a7f618b9b3 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Mon, 3 Jan 2011 21:30:50 +0000 Subject: [PATCH] SOLR-1930: fully move from Field to Fieldable in interfaces git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1054763 13f79535-47bb-0310-9956-ffa450edef68 --- solr/src/java/org/apache/solr/schema/BinaryField.java | 2 +- solr/src/java/org/apache/solr/schema/FieldType.java | 11 +++++------ solr/src/java/org/apache/solr/schema/LatLonType.java | 2 +- solr/src/java/org/apache/solr/schema/PointType.java | 2 +- solr/src/java/org/apache/solr/schema/SchemaField.java | 2 +- .../java/org/apache/solr/schema/TrieDateField.java | 2 +- solr/src/java/org/apache/solr/schema/TrieField.java | 2 +- .../java/org/apache/solr/update/DocumentBuilder.java | 4 ++-- .../test/org/apache/solr/BasicFunctionalityTest.java | 6 ++---- .../apache/solr/update/TestIndexingPerformance.java | 3 ++- 10 files changed, 17 insertions(+), 19 deletions(-) diff --git a/solr/src/java/org/apache/solr/schema/BinaryField.java b/solr/src/java/org/apache/solr/schema/BinaryField.java index 990da2debc4..e78ead4d9f1 100644 --- a/solr/src/java/org/apache/solr/schema/BinaryField.java +++ b/solr/src/java/org/apache/solr/schema/BinaryField.java @@ -50,7 +50,7 @@ public class BinaryField extends FieldType { return ByteBuffer.wrap(f.getBinaryValue(), f.getBinaryOffset(), f.getBinaryLength() ) ; } - public Field createField(SchemaField field, Object val, float boost) { + public Fieldable createField(SchemaField field, Object val, float boost) { if (val == null) return null; if (!field.stored()) { log.trace("Ignoring unstored binary field: " + field); diff --git a/solr/src/java/org/apache/solr/schema/FieldType.java b/solr/src/java/org/apache/solr/schema/FieldType.java index 237750096d0..a92c0f42578 100644 --- a/solr/src/java/org/apache/solr/schema/FieldType.java +++ b/solr/src/java/org/apache/solr/schema/FieldType.java @@ -221,7 +221,7 @@ public abstract class FieldType extends FieldProperties { * * */ - public Field createField(SchemaField field, String externalVal, float boost) { + public Fieldable createField(SchemaField field, String externalVal, float boost) { if (!field.indexed() && !field.stored()) { if (log.isTraceEnabled()) log.trace("Ignoring unindexed/unstored field: " + field); @@ -252,9 +252,9 @@ public abstract class FieldType extends FieldProperties { * @param omitNorms true if norms should be omitted * @param omitTFPos true if term freq and position should be omitted. * @param boost The boost value - * @return the {@link org.apache.lucene.document.Field}. + * @return the {@link org.apache.lucene.document.Fieldable}. */ - protected Field createField(String name, String val, Field.Store storage, Field.Index index, + protected Fieldable createField(String name, String val, Field.Store storage, Field.Index index, Field.TermVector vec, boolean omitNorms, boolean omitTFPos, float boost){ Field f = new Field(name, val, @@ -278,7 +278,7 @@ public abstract class FieldType extends FieldProperties { * @see #isPolyField() */ public Fieldable[] createFields(SchemaField field, String externalVal, float boost) { - Field f = createField( field, externalVal, boost); + Fieldable f = createField( field, externalVal, boost); return f==null ? new Fieldable[]{} : new Fieldable[]{f}; } @@ -341,7 +341,7 @@ public abstract class FieldType extends FieldProperties { public Object toObject(SchemaField sf, BytesRef term) { CharArr ext = new CharArr(term.length); indexedToReadable(term, ext); - Field f = createField(sf, ext.toString(), 1.0f); + Fieldable f = createField(sf, ext.toString(), 1.0f); return toObject(f); } @@ -511,7 +511,6 @@ public abstract class FieldType extends FieldProperties { * @param maxInclusive whether the maximum of the range is inclusive or not * @return a Query instance to perform range search according to given parameters * - * @see org.apache.solr.search.SolrQueryParser#getRangeQuery(String, String, String, boolean) */ public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive) { // constant score mode is now enabled per default diff --git a/solr/src/java/org/apache/solr/schema/LatLonType.java b/solr/src/java/org/apache/solr/schema/LatLonType.java index a28f42c7729..b869b7210f4 100644 --- a/solr/src/java/org/apache/solr/schema/LatLonType.java +++ b/solr/src/java/org/apache/solr/schema/LatLonType.java @@ -281,7 +281,7 @@ public class LatLonType extends AbstractSubTypeFieldType implements SpatialQuery //It never makes sense to create a single field, so make it impossible to happen @Override - public Field createField(SchemaField field, String externalVal, float boost) { + public Fieldable createField(SchemaField field, String externalVal, float boost) { throw new UnsupportedOperationException("LatLonType uses multiple fields. field=" + field.getName()); } diff --git a/solr/src/java/org/apache/solr/schema/PointType.java b/solr/src/java/org/apache/solr/schema/PointType.java index 8c7eeeee75d..4a93333292f 100644 --- a/solr/src/java/org/apache/solr/schema/PointType.java +++ b/solr/src/java/org/apache/solr/schema/PointType.java @@ -112,7 +112,7 @@ public class PointType extends CoordinateFieldType implements SpatialQueryable { * */ @Override - public Field createField(SchemaField field, String externalVal, float boost) { + public Fieldable createField(SchemaField field, String externalVal, float boost) { throw new UnsupportedOperationException("PointType uses multiple fields. field=" + field.getName()); } diff --git a/solr/src/java/org/apache/solr/schema/SchemaField.java b/solr/src/java/org/apache/solr/schema/SchemaField.java index 0b46ded8229..2618fa987b3 100644 --- a/solr/src/java/org/apache/solr/schema/SchemaField.java +++ b/solr/src/java/org/apache/solr/schema/SchemaField.java @@ -89,7 +89,7 @@ public final class SchemaField extends FieldProperties { boolean isBinary() { return (properties & BINARY)!=0; } - public Field createField(String val, float boost) { + public Fieldable createField(String val, float boost) { return type.createField(this,val,boost); } diff --git a/solr/src/java/org/apache/solr/schema/TrieDateField.java b/solr/src/java/org/apache/solr/schema/TrieDateField.java index f62b8105696..7f118704f56 100755 --- a/solr/src/java/org/apache/solr/schema/TrieDateField.java +++ b/solr/src/java/org/apache/solr/schema/TrieDateField.java @@ -160,7 +160,7 @@ public class TrieDateField extends DateField { } @Override - public Field createField(SchemaField field, String externalVal, float boost) { + public Fieldable createField(SchemaField field, String externalVal, float boost) { boolean indexed = field.indexed(); boolean stored = field.stored(); diff --git a/solr/src/java/org/apache/solr/schema/TrieField.java b/solr/src/java/org/apache/solr/schema/TrieField.java index 2e57c90b56b..314bdb38443 100644 --- a/solr/src/java/org/apache/solr/schema/TrieField.java +++ b/solr/src/java/org/apache/solr/schema/TrieField.java @@ -477,7 +477,7 @@ public class TrieField extends FieldType { } @Override - public Field createField(SchemaField field, String externalVal, float boost) { + public Fieldable createField(SchemaField field, String externalVal, float boost) { boolean indexed = field.indexed(); boolean stored = field.stored(); diff --git a/solr/src/java/org/apache/solr/update/DocumentBuilder.java b/solr/src/java/org/apache/solr/update/DocumentBuilder.java index 83d331cbe1e..b6a70ae6c81 100644 --- a/solr/src/java/org/apache/solr/update/DocumentBuilder.java +++ b/solr/src/java/org/apache/solr/update/DocumentBuilder.java @@ -73,7 +73,7 @@ public class DocumentBuilder { } } } else { - Field field = sfield.createField(val, boost); + Fieldable field = sfield.createField(val, boost); if (field != null) { if (!sfield.multiValued()) { String oldValue = map.put(sfield.getName(), val); @@ -201,7 +201,7 @@ public class DocumentBuilder { if (f != null) doc.add(f); // null fields are not added } } else { - Field f = field.createField(val, boost); + Fieldable f = field.createField(val, boost); if (f != null) doc.add(f); // null fields are not added } } diff --git a/solr/src/test/org/apache/solr/BasicFunctionalityTest.java b/solr/src/test/org/apache/solr/BasicFunctionalityTest.java index 7cac48d9c17..7662ca0eff1 100644 --- a/solr/src/test/org/apache/solr/BasicFunctionalityTest.java +++ b/solr/src/test/org/apache/solr/BasicFunctionalityTest.java @@ -27,9 +27,8 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.lucene.document.Field; +import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.LogMergePolicy; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.Query; import org.apache.solr.common.params.AppendedSolrParams; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.DefaultSolrParams; @@ -47,7 +46,6 @@ import org.apache.solr.schema.IndexSchema; import org.apache.solr.schema.SchemaField; import org.apache.solr.search.DocIterator; import org.apache.solr.search.DocList; -import org.apache.solr.search.QueryParsing; import org.apache.solr.update.SolrIndexWriter; import org.junit.BeforeClass; import org.junit.Test; @@ -350,7 +348,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 { IndexSchema ischema = new IndexSchema(solrConfig, getSchemaFile(), null); SchemaField f; // Solr field type - Field luf; // Lucene field + Fieldable luf; // Lucene field f = ischema.getField("test_basictv"); luf = f.createField("test", 0f); diff --git a/solr/src/test/org/apache/solr/update/TestIndexingPerformance.java b/solr/src/test/org/apache/solr/update/TestIndexingPerformance.java index d2ea03a7dec..f513a94ca1d 100755 --- a/solr/src/test/org/apache/solr/update/TestIndexingPerformance.java +++ b/solr/src/test/org/apache/solr/update/TestIndexingPerformance.java @@ -19,6 +19,7 @@ package org.apache.solr.update; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.Fieldable; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.schema.IndexSchema; import org.apache.solr.util.AbstractSolrTestCase; @@ -99,7 +100,7 @@ public class TestIndexingPerformance extends AbstractSolrTestCase { for (int j=0; j