Examples of NumericConfig


Examples of org.apache.lucene.queryParser.standard.config.NumericConfig

    HashMap<String,NumericConfig> numericConfigMap = new HashMap<String,NumericConfig>();
    HashMap<String,NumericField> numericFieldMap = new HashMap<String,NumericField>();
    qp.setNumericConfigMap(numericConfigMap);
   
    for (NumericField.DataType type : NumericField.DataType.values()) {
      numericConfigMap.put(type.name(), new NumericConfig(PRECISION_STEP,
          NUMBER_FORMAT, type));
     
      NumericField field = new NumericField(type.name(), PRECISION_STEP,
          Field.Store.YES, true);
     
      numericFieldMap.put(type.name(), field);
      doc.add(field);
     
    }
   
    numericConfigMap.put(DATE_FIELD_NAME, new NumericConfig(PRECISION_STEP,
        DATE_FORMAT, NumericField.DataType.LONG));
    NumericField dateField = new NumericField(DATE_FIELD_NAME, PRECISION_STEP,
        Field.Store.YES, true);
    numericFieldMap.put(DATE_FIELD_NAME, dateField);
    doc.add(dateField);
View Full Code Here

Examples of org.apache.lucene.queryParser.standard.config.NumericConfig

        FieldConfig fieldConfig = config.getFieldConfig(StringUtils
            .toString(parametricRangeNode.getField()));
       
        if (fieldConfig != null) {
         
          NumericConfig numericConfig = fieldConfig
              .get(ConfigurationKeys.NUMERIC_CONFIG);
         
          if (numericConfig != null) {
           
            ParametricQueryNode lower = parametricRangeNode.getLowerBound();
            ParametricQueryNode upper = parametricRangeNode.getUpperBound();
           
            NumberFormat numberFormat = numericConfig.getNumberFormat();
            Number lowerNumber, upperNumber;
           
            try {
              lowerNumber = numberFormat.parse(lower.getTextAsString());
             
            } catch (ParseException e) {
              throw new QueryNodeParseException(new MessageImpl(
                  QueryParserMessages.COULD_NOT_PARSE_NUMBER, lower
                      .getTextAsString(), numberFormat.getClass()
                      .getCanonicalName()), e);
            }
           
            try {
              upperNumber = numberFormat.parse(upper.getTextAsString());
             
            } catch (ParseException e) {
              throw new QueryNodeParseException(new MessageImpl(
                  QueryParserMessages.COULD_NOT_PARSE_NUMBER, upper
                      .getTextAsString(), numberFormat.getClass()
                      .getCanonicalName()), e);
            }
           
            switch (numericConfig.getType()) {
              case LONG:
                upperNumber = upperNumber.longValue();
                lowerNumber = lowerNumber.longValue();
                break;
              case INT:
View Full Code Here

Examples of org.apache.lucene.queryParser.standard.config.NumericConfig

      upperNumber = upperNumericNode.getValue();
    } else {
      upperNumber = null;
    }
   
    NumericConfig numericConfig = numericRangeNode.getNumericConfig();
    NumericField.DataType numberType = numericConfig.getType();
    String field = StringUtils.toString(numericRangeNode.getField());
    boolean minInclusive = numericRangeNode.isLowerInclusive();
    boolean maxInclusive = numericRangeNode.isUpperInclusive();
    int precisionStep = numericConfig.getPrecisionStep();
   
    switch (numberType) {
     
      case LONG:
        return NumericRangeQuery.newLongRange(field, precisionStep,
View Full Code Here

Examples of org.apache.lucene.queryParser.standard.config.NumericConfig

        FieldQueryNode fieldNode = (FieldQueryNode) node;
        FieldConfig fieldConfig = config.getFieldConfig(fieldNode
            .getFieldAsString());
       
        if (fieldConfig != null) {
          NumericConfig numericConfig = fieldConfig
              .get(ConfigurationKeys.NUMERIC_CONFIG);
         
          if (numericConfig != null) {
           
            NumberFormat numberFormat = numericConfig.getNumberFormat();
            Number number;
           
            try {
              number = numberFormat.parse(fieldNode.getTextAsString());
             
            } catch (ParseException e) {
              throw new QueryNodeParseException(new MessageImpl(
                  QueryParserMessages.COULD_NOT_PARSE_NUMBER, fieldNode
                      .getTextAsString(), numberFormat.getClass()
                      .getCanonicalName()), e);
            }
           
            switch (numericConfig.getType()) {
              case LONG:
                number = number.longValue();
                break;
              case INT:
                number = number.intValue();
View Full Code Here

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

    HashMap<String,NumericConfig> numericConfigMap = new HashMap<String,NumericConfig>();
    HashMap<String,Field> numericFieldMap = new HashMap<String,Field>();
    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

    HashMap<String,NumericConfig> numericConfigMap = new HashMap<String,NumericConfig>();
    HashMap<String,Field> numericFieldMap = new HashMap<String,Field>();
    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

        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

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

    NumericQueryNode upperNumericNode = numericRangeNode.getUpperBound();
   
    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();
   
    switch (numberType) {
     
      case LONG:
        return NumericRangeQuery.newLongRange(field, precisionStep,
View Full Code Here

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

        FieldQueryNode fieldNode = (FieldQueryNode) node;
        FieldConfig fieldConfig = config.getFieldConfig(fieldNode
            .getFieldAsString());
       
        if (fieldConfig != null) {
          NumericConfig numericConfig = fieldConfig
              .get(ConfigurationKeys.NUMERIC_CONFIG);
         
          if (numericConfig != null) {
           
            NumberFormat numberFormat = numericConfig.getNumberFormat();
            String text = fieldNode.getTextAsString();
            Number number = null;
           
            if (text.length() > 0) {
             
              try {
                number = numberFormat.parse(text);
               
              } catch (ParseException e) {
                throw new QueryNodeParseException(new MessageImpl(
                    QueryParserMessages.COULD_NOT_PARSE_NUMBER, fieldNode
                        .getTextAsString(), numberFormat.getClass()
                        .getCanonicalName()), e);
              }
             
              switch (numericConfig.getType()) {
                case LONG:
                  number = number.longValue();
                  break;
                case INT:
                  number = number.intValue();
View Full Code Here

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

        FieldConfig fieldConfig = config.getFieldConfig(StringUtils
            .toString(termRangeNode.getField()));
       
        if (fieldConfig != null) {
         
          NumericConfig numericConfig = fieldConfig
              .get(ConfigurationKeys.NUMERIC_CONFIG);
         
          if (numericConfig != null) {
           
            FieldQueryNode lower = termRangeNode.getLowerBound();
            FieldQueryNode upper = termRangeNode.getUpperBound();
           
            String lowerText = lower.getTextAsString();
            String upperText = upper.getTextAsString();
            NumberFormat numberFormat = numericConfig.getNumberFormat();
            Number lowerNumber = null, upperNumber = null;
           
             if (lowerText.length() > 0) {
             
              try {
                lowerNumber = numberFormat.parse(lowerText);
               
              } catch (ParseException e) {
                throw new QueryNodeParseException(new MessageImpl(
                    QueryParserMessages.COULD_NOT_PARSE_NUMBER, lower
                        .getTextAsString(), numberFormat.getClass()
                        .getCanonicalName()), e);
              }
             
            }
           
             if (upperText.length() > 0) {
           
              try {
                upperNumber = numberFormat.parse(upperText);
               
              } catch (ParseException e) {
                throw new QueryNodeParseException(new MessageImpl(
                    QueryParserMessages.COULD_NOT_PARSE_NUMBER, upper
                        .getTextAsString(), numberFormat.getClass()
                        .getCanonicalName()), e);
              }
           
            }
           
            switch (numericConfig.getType()) {
              case LONG:
                if (upperNumber != null) upperNumber = upperNumber.longValue();
                if (lowerNumber != null) lowerNumber = lowerNumber.longValue();
                break;
              case INT:
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.