Search in sources :

Example 21 with LegacyIntField

use of org.apache.solr.legacy.LegacyIntField in project lucene-solr by apache.

the class EnumField method createField.

/**
   * {@inheritDoc}
   */
@Override
public IndexableField createField(SchemaField field, Object value) {
    final boolean indexed = field.indexed();
    final boolean stored = field.stored();
    final boolean docValues = field.hasDocValues();
    if (!indexed && !stored && !docValues) {
        if (log.isTraceEnabled())
            log.trace("Ignoring unindexed/unstored field: " + field);
        return null;
    }
    final Integer intValue = stringValueToIntValue(value.toString());
    if (intValue == null || intValue.equals(DEFAULT_VALUE))
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown value for enum field: " + value.toString());
    final LegacyFieldType newType = new LegacyFieldType();
    newType.setTokenized(field.isTokenized());
    newType.setStored(field.stored());
    newType.setOmitNorms(field.omitNorms());
    newType.setIndexOptions(field.indexOptions());
    newType.setStoreTermVectors(field.storeTermVector());
    newType.setStoreTermVectorOffsets(field.storeTermOffsets());
    newType.setStoreTermVectorPositions(field.storeTermPositions());
    newType.setStoreTermVectorPayloads(field.storeTermPayloads());
    newType.setNumericType(LegacyNumericType.INT);
    newType.setNumericPrecisionStep(DEFAULT_PRECISION_STEP);
    return new LegacyIntField(field.getName(), intValue.intValue(), newType);
}
Also used : LegacyFieldType(org.apache.solr.legacy.LegacyFieldType) SolrException(org.apache.solr.common.SolrException) LegacyIntField(org.apache.solr.legacy.LegacyIntField)

Aggregations

LegacyIntField (org.apache.solr.legacy.LegacyIntField)21 Document (org.apache.lucene.document.Document)18 Directory (org.apache.lucene.store.Directory)15 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)13 DirectoryReader (org.apache.lucene.index.DirectoryReader)8 IndexReader (org.apache.lucene.index.IndexReader)8 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)7 LeafReader (org.apache.lucene.index.LeafReader)7 BytesRef (org.apache.lucene.util.BytesRef)7 IndexWriter (org.apache.lucene.index.IndexWriter)6 IndexSearcher (org.apache.lucene.search.IndexSearcher)6 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)5 Sort (org.apache.lucene.search.Sort)5 SortField (org.apache.lucene.search.SortField)5 TopDocs (org.apache.lucene.search.TopDocs)5 LegacyFieldType (org.apache.solr.legacy.LegacyFieldType)5 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)4 SortedSetDocValues (org.apache.lucene.index.SortedSetDocValues)4 LegacyLongField (org.apache.solr.legacy.LegacyLongField)4 HashSet (java.util.HashSet)3