/** Returns true if a single field value of this type has multiple logical values * for the purposes of faceting, sorting, etc. Text fields normally return * true since each token/word is a logical value. */ public boolean multiValuedFieldCache() { return isTokenized(); }
protected Field.Index getFieldIndex(SchemaField field, String internalVal) { return field.indexed() ? (isTokenized() ? Field.Index.TOKENIZED : Field.Index.UN_TOKENIZED) : Field.Index.NO; }
/** * Method that checks if proper field collapsing is actually possible with the current collapse field. * If the collapse field does not meet the proper requirements a runtime exception is thrown. * A runtime exception is thrown under the following circumstances: * <ul> * <li> When the collapse field does not exists in the schema * <li> When the collapse field is multivalued in the schema * <li> When the collapse field is tokenized in the schema * </ul> * * For example when a field is tokenized, only the last token of the field can be retrieved from the fieldcache. This * results in field collapsing only on the last token of a field value instead of the complete field value. * * When the field values from a multivalued field are returned from the <code>FieldCache</code> then an exception may * be thrown. This happens when there are more terms in a field than documents. * * @param schema The index schema */ protected void checkCollapseField(IndexSchema schema) { SchemaField schemaField = schema.getFieldOrNull(collapseField); if (schemaField == null) { throw new RuntimeException("Could not collapse, because collapse field does not exist in the schema."); } if (schemaField.multiValued()) { throw new RuntimeException("Could not collapse, because collapse field is multivalued"); } if (schemaField.getType().isTokenized()) { throw new RuntimeException("Could not collapse, because collapse field is tokenized"); } }
/** * @return a string representing a SchemaField's flags. */ private static String getFieldFlags( SchemaField f ) { FieldType t = (f==null) ? null : f.getType(); // see: http://www.nabble.com/schema-field-properties-tf3437753.html#a9585549 boolean lazy = false; // "lazy" is purely a property of reading fields boolean binary = false; // Currently not possible StringBuilder flags = new StringBuilder(); flags.append( (f != null && f.indexed()) ? FieldFlag.INDEXED.getAbbreviation() : '-' ); flags.append( (t != null && t.isTokenized()) ? FieldFlag.TOKENIZED.getAbbreviation() : '-' ); flags.append( (f != null && f.stored()) ? FieldFlag.STORED.getAbbreviation() : '-' ); flags.append( (f != null && f.multiValued()) ? FieldFlag.MULTI_VALUED.getAbbreviation() : '-' ); flags.append( (f != null && f.storeTermVector() ) ? FieldFlag.TERM_VECTOR_STORED.getAbbreviation() : '-' ); flags.append( (f != null && f.storeTermOffsets() ) ? FieldFlag.TERM_VECTOR_OFFSET.getAbbreviation() : '-' ); flags.append( (f != null && f.storeTermPositions() ) ? FieldFlag.TERM_VECTOR_POSITION.getAbbreviation() : '-' ); flags.append( (f != null && f.omitNorms()) ? FieldFlag.OMIT_NORMS.getAbbreviation() : '-' ); flags.append( (f != null && f.omitTf()) ? FieldFlag.OMIT_TF.getAbbreviation() : '-' ); flags.append( (lazy) ? FieldFlag.LAZY.getAbbreviation() : '-' ); flags.append( (binary) ? FieldFlag.BINARY.getAbbreviation() : '-' ); flags.append( (f != null && f.isCompressed()) ? FieldFlag.COMPRESSED.getAbbreviation() : '-' ); flags.append( (f != null && f.sortMissingFirst() ) ? FieldFlag.SORT_MISSING_FIRST.getAbbreviation() : '-' ); flags.append( (f != null && f.sortMissingLast() ) ? FieldFlag.SORT_MISSING_LAST.getAbbreviation() : '-' ); return flags.toString(); }
SimpleOrderedMap<Object> field = new SimpleOrderedMap<Object>(); field.add("fields", typeusemap.get( ft.getTypeName() ) ); field.add("tokenized", ft.isTokenized() ); field.add("className", ft.getClass().getName()); field.add("indexAnalyzer", getAnalyzerInfo(ft.getAnalyzer()));
@Test public void testSirenFieldTypeProperties() throws Exception { final IndexSchema schema = h.getCore().getSchema(); final FieldType type = schema.getField("json").getType(); assertTrue(type instanceof SirenField); assertFalse(type.isMultiValued()); assertTrue(type.isTokenized()); assertEquals(type.getPostingsFormat(), Siren10AForPostingsFormat.NAME); }
@Test public void testSirenFieldTypeProperties() throws Exception { final IndexSchema schema = h.getCore().getLatestSchema(); final FieldType type = schema.getField("json").getType(); assertTrue(type instanceof ExtendedJsonField); assertFalse(type.isMultiValued()); assertTrue(type.isTokenized()); assertEquals(type.getPostingsFormat(), Siren10AForPostingsFormat.NAME); }