Package org.apache.lucene.document.FieldType

Examples of org.apache.lucene.document.FieldType.NumericType


    final Document doc2 = new Document();
    for(IndexableField f : doc1.getFields()) {
      final Field field1 = (Field) f;
      final Field field2;
      final DocValuesType dvType = field1.fieldType().docValueType();
      final NumericType numType = field1.fieldType().numericType();
      if (dvType != null) {
        switch(dvType) {
          case NUMERIC:
            field2 = new NumericDocValuesField(field1.name(), field1.numericValue().longValue());
            break;
View Full Code Here


  private void buildDocument(Document document, Serializer serializer) {
    final List<IndexableField> docFields = document.getFields();
    serializer.fields( docFields );
    for ( IndexableField fieldable : docFields ) {
      final FieldType fieldType = (FieldType) fieldable.fieldType();
      final NumericType numericType = fieldType.numericType();
      if ( numericType != null ) {
        LuceneNumericFieldContext context = new LuceneNumericFieldContext( fieldType, fieldable.name(), fieldable.boost() );
        switch ( numericType ) {
          case INT:
            serializer.addIntNumericField( fieldable.numericValue().intValue(), context );
            break;
          case LONG:
            serializer.addLongNumericField( fieldable.numericValue().longValue(), context );
            break;
          case FLOAT:
            serializer.addFloatNumericField( fieldable.numericValue().floatValue(), context );
            break;
          case DOUBLE:
            serializer.addDoubleNumericField( fieldable.numericValue().doubleValue(), context );
            break;
          default:
            String dataType = numericType.toString();
            throw log.unknownNumericFieldType( dataType );
        }
      }
      else if (fieldable instanceof Field) {
        Field safeField = (Field) fieldable;
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.FieldType.NumericType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.