List of usage examples for org.apache.solr.schema SchemaField omitTermFreqAndPositions
public boolean omitTermFreqAndPositions()
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 w w w . ja v a 2 s . co 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 w w 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; }