Example usage for org.apache.solr.schema SchemaField omitNorms

List of usage examples for org.apache.solr.schema SchemaField omitNorms

Introduction

In this page you can find the example usage for org.apache.solr.schema SchemaField omitNorms.

Prototype

public boolean omitNorms() 

Source Link

Usage

From source file:com.sindicetech.siren.solr.schema.ExtendedJsonField.java

License:Open Source License

@Override
public IndexableField createField(final SchemaField field, final Object value, final float boost) {
    if (!field.indexed()) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "ExtendedJsonField instances must be indexed: " + field.getName());
    }//from  ww w .  j av a2  s . c o m
    if (field.multiValued()) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "ExtendedJsonField instances can not be multivalued: " + field.getName());
    }
    if (!field.omitNorms()) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "ExtendedJsonField instances must omit norms: " + field.getName());
    }
    if (field.omitTermFreqAndPositions()) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "ExtendedJsonField instances must not omit term " + "frequencies and positions: "
                        + field.getName());
    }
    if (field.omitPositions()) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "ExtendedJsonField instances must not omit term " + "positions: " + field.getName());
    }
    if (field.storeTermVector()) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "ExtendedJsonField instances can not store term vectors: " + field.getName());
    }
    return super.createField(field, value, boost);
}

From source file:fi.nationallibrary.ndl.solr.schema.CompressedStrField.java

License:Apache License

@Override
public Fieldable createField(SchemaField field, String externalVal, float boost) {
    if (!field.indexed() && !field.stored()) {
        if (log.isTraceEnabled())
            log.trace("Ignoring unindexed/unstored field: " + field);
        return null;
    }/*from ww w  .  j a  v  a2 s. c o m*/

    String val = null;
    try {
        val = toInternal(externalVal);
    } catch (RuntimeException e) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "Error while creating field '" + field + "' from value '" + externalVal + "'", e, false);
    }
    if (val == null)
        return null;

    Fieldable f;
    if (val.length() > compressionThreshold) {
        f = new CompressedField(field.getName(), val, getFieldStore(field, val), getFieldIndex(field, val),
                getFieldTermVec(field, val), compressionLevel);
    } else {
        f = new Field(field.getName(), val, getFieldStore(field, val), getFieldIndex(field, val),
                getFieldTermVec(field, val));
    }
    f.setOmitNorms(field.omitNorms());
    if (field.omitTermFreqAndPositions()) {
        if (field.omitPositions()) {
            f.setIndexOptions(IndexOptions.DOCS_ONLY);
        } else {
            f.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
        }
    } else {
        f.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
    }
    f.setBoost(boost);

    return f;
}

From source file:no.trank.openpipe.solr.schema.Base64Type.java

License:Apache License

/**
 * Creates a field from a pre-tokenized field from a binary base64-encoded string.
 * /*from  w  ww  .  ja va  2s.  c  o m*/
 * @param field the field info as read from schema.
 * @param externalVal the base64-encoded string.
 * @param boost the boost of this field.
 * 
 * @return a <tt>Fieldable</tt> as read from <tt>externalVal</tt> described {@linkplain Base64Type here}.
 */
@Override
public Fieldable createField(SchemaField field, String externalVal, float boost) {
    if (externalVal == null) {
        return null;
    }
    if (!field.indexed() && !field.stored()) {
        log.finest("Ignoring unindexed/unstored field: " + field);
        return null;
    }
    InputStream in = new Base64InputStream(externalVal);
    try {
        if (BinaryIO.readHeaderIsCompressed(in)) {
            in = new InflaterInputStream(in);
        }
        final String val = IOUtil.readUTF(in);
        final Fieldable f = new Base64Field(field.getName(), val, getFieldStore(field, val),
                getFieldIndex(field, val), getFieldTermVec(field, val), in);
        f.setOmitNorms(field.omitNorms());
        f.setBoost(boost);
        return f;
    } catch (IOException e) {
        throw new SolrException(SERVER_ERROR,
                "Could not create field '" + field + "' from value '" + externalVal + "'", e, false);
    }
}