private void putInFieldTypeBucket(Set<String> stringEncodedFieldNames, Set<String> numericEncodedFieldNames, FieldDescriptor fieldDescriptor) { if ( FieldDescriptor.Type.NUMERIC.equals( fieldDescriptor.getType() ) ) { // If the property allows to index a string based null token, a non numeric query is ok // We are currently skipping this case completely from the validation. In a full on implementation we would // need to take term values into account and in the case of a string query only allow the null token. // For now we cast a net which is potentially too wide (HF) if ( !fieldDescriptor.indexNull() ) { numericEncodedFieldNames.add( fieldDescriptor.getName() ); } } else { stringEncodedFieldNames.add( fieldDescriptor.getName() ); } }
@Test public void testFieldDescriptorNullIndexOptions() { FieldDescriptor fieldDescriptor = getFieldDescriptor( Snafu.class, "nullValue" ); assertTrue( fieldDescriptor.indexNull() ); assertEquals( "snafu", fieldDescriptor.indexNullAs() ); }
@Test public void testFieldDescriptorDefaultNullIndexOptions() { FieldDescriptor fieldDescriptor = getFieldDescriptor( Snafu.class, "my-snafu" ); assertFalse( fieldDescriptor.indexNull() ); assertNull( fieldDescriptor.indexNullAs() ); }
private void putInFieldTypeBucket(Set<String> stringEncodedFieldNames, Set<String> numericEncodedFieldNames, FieldDescriptor fieldDescriptor) { if ( FieldDescriptor.Type.NUMERIC.equals( fieldDescriptor.getType() ) ) { // If the property allows to index a string based null token, a non numeric query is ok // We are currently skipping this case completely from the validation. In a full on implementation we would // need to take term values into account and in the case of a string query only allow the null token. // For now we cast a net which is potentially too wide (HF) if ( !fieldDescriptor.indexNull() ) { numericEncodedFieldNames.add( fieldDescriptor.getName() ); } } else { stringEncodedFieldNames.add( fieldDescriptor.getName() ); } }
@Test public void testFieldDescriptorLuceneOptions() { String fieldName = "my-snafu"; FieldDescriptor fieldDescriptor = getFieldDescriptor( Snafu.class, fieldName ); assertEquals( "Wrong field name", fieldName, fieldDescriptor.getName() ); assertEquals( Index.NO, fieldDescriptor.getIndex() ); assertEquals( Analyze.NO, fieldDescriptor.getAnalyze() ); assertEquals( Store.YES, fieldDescriptor.getStore() ); assertEquals( Norms.NO, fieldDescriptor.getNorms() ); assertEquals( TermVector.WITH_POSITIONS, fieldDescriptor.getTermVector() ); assertEquals( 10.0f, fieldDescriptor.getBoost(), 0 ); assertFalse( fieldDescriptor.indexNull() ); assertNull( fieldDescriptor.indexNullAs() ); assertTrue( FieldSettingsDescriptor.Type.BASIC.equals( fieldDescriptor.getType() ) ); }