queryString.append("\n").append(intend).append("FILTER "); // start the boolean closedRange = constraint.getLowerBound() != null && constraint.getUpperBound() != null; if (closedRange) { queryString.append("("); if (constraint.getLowerBound() != null) { addRangeBound(queryString, var, true, constraint.isInclusive(), constraint.getLowerBound()); if (constraint.getUpperBound() != null) { addRangeBound(queryString, var, false, constraint.isInclusive(), constraint.getUpperBound());
throw new IllegalArgumentException(message.toString()); } else { constraint = new RangeConstraint(lowerBound, upperBound, inclusive);
queryString.append("\n").append(intend).append("FILTER "); // start the boolean closedRange = constraint.getLowerBound() != null && constraint.getUpperBound() != null; if (closedRange) { queryString.append("("); if (constraint.getLowerBound() != null) { addRangeBound(queryString, var, true, constraint.isInclusive(), constraint.getLowerBound()); if (constraint.getUpperBound() != null) { addRangeBound(queryString, var, false, constraint.isInclusive(), constraint.getUpperBound());
/** * Tests simple {@link RangeConstraint} */ @Test public void testFindRange(){ //init the test data FieldQueryTestData data = getFieldQueryTestData(); //query for all languages and value1 FieldQuery query = getYard().getQueryFactory().createFieldQuery(); query.setConstraint(data.intField, new RangeConstraint(data.intValue2,data.intValue5,true)); query.addSelectedField(data.intField); query.addSelectedField(data.refField); validateQueryResults(query, getYard().find(query), Arrays.asList(data.r2.getId(), data.r2en.getId(), data.r2de.getId(), data.r5.getId()), Arrays.asList(data.intField, data.refField)); //same for value2 query = getYard().getQueryFactory().createFieldQuery(); query.setConstraint(data.intField, new RangeConstraint(data.intValue2,data.intValue10,false)); query.addSelectedField(data.intField); query.addSelectedField(data.textField); validateQueryResults(query, getYard().find(query), Arrays.asList(data.r5.getId()), Arrays.asList(data.intField, data.textField)); } /**
addBoost(upperBound, rangeConstraint); if (rangeConstraint.getLowerBound() != null) { IndexValue value = indexValueFactory.createIndexValue(rangeConstraint.getLowerBound()); lowerBound.getValues().add(value); dataType = value.getType(); if (rangeConstraint.getUpperBound() != null) { IndexValue value = indexValueFactory.createIndexValue(rangeConstraint.getUpperBound()); upperBound.getValues().add(value); IndexDataType upperDataType = value.getType(); "and lover Bound! (lower:[value=%s|datatype=%s] | " + "upper:[value=%s|datatype=%s])", rangeConstraint.getLowerBound(), dataType, rangeConstraint.getUpperBound(), upperDataType)); if (rangeConstraint.isInclusive()) { indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.LE, upperBound); indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.GE, lowerBound);
query.setConstraint(data.intField, new RangeConstraint(data.intValue2,data.intValue5, true));
addBoost(upperBound, rangeConstraint); if (rangeConstraint.getLowerBound() != null) { IndexValue value = indexValueFactory.createIndexValue(rangeConstraint.getLowerBound()); lowerBound.getValues().add(value); dataType = value.getType(); if (rangeConstraint.getUpperBound() != null) { IndexValue value = indexValueFactory.createIndexValue(rangeConstraint.getUpperBound()); upperBound.getValues().add(value); IndexDataType upperDataType = value.getType(); "and lover Bound! (lower:[value=%s|datatype=%s] | " + "upper:[value=%s|datatype=%s])", rangeConstraint.getLowerBound(), dataType, rangeConstraint.getUpperBound(), upperDataType)); if (rangeConstraint.isInclusive()) { indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.LE, upperBound); indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.GE, lowerBound);
RangeConstraint rangeConstraint = (RangeConstraint) constraint; Set<DataTypeEnum> dataTypes = EnumSet.noneOf(DataTypeEnum.class); if (rangeConstraint.getLowerBound() != null) { jConstraint.put("lowerBound", rangeConstraint.getLowerBound()); dataTypes.addAll(DataTypeEnum.getPrimaryDataTypes( rangeConstraint.getLowerBound().getClass())); if (rangeConstraint.getUpperBound() != null) { jConstraint.put("upperBound", rangeConstraint.getUpperBound()); dataTypes.addAll(DataTypeEnum.getPrimaryDataTypes( rangeConstraint.getUpperBound().getClass())); jConstraint.put("inclusive", rangeConstraint.isInclusive()); if(!dataTypes.isEmpty()){ jConstraint.put("datatype", dataTypes.iterator().next().getShortName());