Examples of NumericConfig


Examples of org.apache.lucene.queryparser.flexible.standard.config.NumericConfig

    HashMap<String,NumericConfig> numericConfigMap = new HashMap<>();
    HashMap<String,Field> numericFieldMap = new HashMap<>();
    qp.setNumericConfigMap(numericConfigMap);
   
    for (NumericType type : NumericType.values()) {
      numericConfigMap.put(type.name(), new NumericConfig(PRECISION_STEP,
          NUMBER_FORMAT, type));

      FieldType ft = new FieldType(IntField.TYPE_NOT_STORED);
      ft.setNumericType(type);
      ft.setStored(true);
      ft.setNumericPrecisionStep(PRECISION_STEP);
      ft.freeze();
      final Field field;

      switch(type) {
      case INT:
        field = new IntField(type.name(), 0, ft);
        break;
      case FLOAT:
        field = new FloatField(type.name(), 0.0f, ft);
        break;
      case LONG:
        field = new LongField(type.name(), 0l, ft);
        break;
      case DOUBLE:
        field = new DoubleField(type.name(), 0.0, ft);
        break;
      default:
        fail();
        field = null;
      }
      numericFieldMap.put(type.name(), field);
      doc.add(field);
    }
   
    numericConfigMap.put(DATE_FIELD_NAME, new NumericConfig(PRECISION_STEP,
        DATE_FORMAT, NumericType.LONG));
    FieldType ft = new FieldType(LongField.TYPE_NOT_STORED);
    ft.setStored(true);
    ft.setNumericPrecisionStep(PRECISION_STEP);
    LongField dateField = new LongField(DATE_FIELD_NAME, 0l, ft);
View Full Code Here

Examples of org.apache.lucene.queryparser.flexible.standard.config.NumericConfig

    {
        super(analyzer);

        // All fields indexed numerically need to be listed here in order to properly search on them.
        Map<String, NumericConfig> numericConfigMap = new HashMap<String, NumericConfig>();
        numericConfigMap.put("year", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.INT));
        numericConfigMap.put("modified", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.LONG));
        numericConfigMap.put("published", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.LONG));
        numericConfigMap.put("when", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.LONG));
        this.setNumericConfigMap(numericConfigMap);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.