Package org.apache.lucene.document.FieldType

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


    for(int id=0;id<numDocs;id++) {
      Document doc = new Document();
      final Field nf;
      final Field sf;
      final Number answer;
      final NumericType typeAnswer;
      if (random().nextBoolean()) {
        // float/double
        if (random().nextBoolean()) {
          final float f = random().nextFloat();
          answer = Float.valueOf(f);
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

    for(int id=0;id<numDocs;id++) {
      Document doc = new Document();
      final Field nf;
      final Field sf;
      final Number answer;
      final NumericType typeAnswer;
      if (random().nextBoolean()) {
        // float/double
        if (random().nextBoolean()) {
          final float f = random().nextFloat();
          answer = Float.valueOf(f);
View Full Code Here

    for(int id=0;id<numDocs;id++) {
      Document doc = new Document();
      final Field nf;
      final Field sf;
      final Number answer;
      final NumericType typeAnswer;
      if (random().nextBoolean()) {
        // float/double
        if (random().nextBoolean()) {
          final float f = random().nextFloat();
          answer = Float.valueOf(f);
View Full Code Here

  public TokenStream tokenStream(Analyzer analyzer) throws IOException {
    if (!fieldType().indexed()) {
      return null;
    }

    final NumericType numericType = fieldType().numericType();
    if (numericType != null) {
      if (!(internalTokenStream instanceof NumericTokenStream)) {
        // lazy init the TokenStream as it is heavy to instantiate
        // (attributes,...) if not needed (stored field loading)
        internalTokenStream = new NumericTokenStream(type.numericPrecisionStep());
View Full Code Here

        Map<String, NumericConfig> numericMap = new HashMap<String, NumericConfig>();
        for (LuceneConfigNumericField field : _luceneConfig.getNumericFields().values()) {
            String name = field.getName();
            int precisionStep = field.getPrecisionStep();
            NumberFormat format = NumberFormat.getNumberInstance();
            NumericType type = NumericType.valueOf(field.getType().toUpperCase());
            NumericConfig config = new NumericConfig(precisionStep, format, type);
            numericMap.put(name, config);
        }
        parser.setNumericConfigMap(numericMap);
        Query q = parser.parse(cswServiceSpecificConstraint, "title");
View Full Code Here

  public TokenStream tokenStream(Analyzer analyzer) throws IOException {
    if (!fieldType().indexed()) {
      return null;
    }

    final NumericType numericType = fieldType().numericType();
    if (numericType != null) {
      if (!(internalTokenStream instanceof NumericTokenStream)) {
        // lazy init the TokenStream as it is heavy to instantiate
        // (attributes,...) if not needed (stored field loading)
        internalTokenStream = new NumericTokenStream(type.numericPrecisionStep());
View Full Code Here

   
    Number lowerNumber = lowerNumericNode.getValue();
    Number upperNumber = upperNumericNode.getValue();
   
    NumericConfig numericConfig = numericRangeNode.getNumericConfig();
    NumericType numberType = numericConfig.getType();
    String field = StringUtils.toString(numericRangeNode.getField());
    boolean minInclusive = numericRangeNode.isLowerInclusive();
    boolean maxInclusive = numericRangeNode.isUpperInclusive();
    int precisionStep = numericConfig.getPrecisionStep();
   
View Full Code Here

   
    if (numericConfig == null) {
      throw new IllegalArgumentException("numericConfig cannot be null!");
    }
   
    NumericType lowerNumberType, upperNumberType;
   
    if (lower != null && lower.getValue() != null) {
      lowerNumberType = getNumericDataType(lower.getValue());
    } else {
      lowerNumberType = null;
    }
   
    if (upper != null && upper.getValue() != null) {
      upperNumberType = getNumericDataType(upper.getValue());
    } else {
      upperNumberType = null;
    }
   
    if (lowerNumberType != null
        && !lowerNumberType.equals(numericConfig.getType())) {
      throw new IllegalArgumentException(
          "lower value's type should be the same as numericConfig type: "
              + lowerNumberType + " != " + numericConfig.getType());
    }
   
View Full Code Here

    for(int id=0;id<numDocs;id++) {
      Document doc = new Document();
      final Field nf;
      final Field sf;
      final Number answer;
      final NumericType typeAnswer;
      if (random().nextBoolean()) {
        // float/double
        if (random().nextBoolean()) {
          final float f = random().nextFloat();
          answer = Float.valueOf(f);
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.