use of org.apache.stanbol.entityhub.yard.solr.impl.SolrQueryFactory.ConstraintValue in project stanbol by apache.
the class LeEncoder method encode.
@Override
public void encode(EncodedConstraintParts constraint, Object value) {
IndexValue indexValue;
Double boost = null;
if (value == null) {
// default value
indexValue = null;
} else if (value instanceof IndexValue) {
indexValue = (IndexValue) value;
} else if (value instanceof ConstraintValue) {
ConstraintValue cv = (ConstraintValue) value;
indexValue = cv.getValues() == null || cv.getValues().isEmpty() ? null : cv.getValues().iterator().next();
boost = cv.getBoost();
} else {
indexValue = indexValueFactory.createIndexValue(value);
}
StringBuilder leConstraint = new StringBuilder("TO ");
if (indexValue != null && indexValue.getValue() != null && !indexValue.getValue().isEmpty()) {
leConstraint.append(indexValue.getValue());
} else {
leConstraint.append(DEFAULT);
}
leConstraint.append(']');
if (boost != null) {
leConstraint.append("^").append(boost);
}
constraint.addEncoded(POS, leConstraint.toString());
}
use of org.apache.stanbol.entityhub.yard.solr.impl.SolrQueryFactory.ConstraintValue in project stanbol by apache.
the class GtEncoder method encode.
@Override
public void encode(EncodedConstraintParts constraint, Object value) {
IndexValue indexValue;
if (value == null) {
// default value
indexValue = null;
} else if (value instanceof IndexValue) {
indexValue = (IndexValue) value;
} else if (value instanceof ConstraintValue) {
ConstraintValue cv = (ConstraintValue) value;
indexValue = cv.getValues() == null || cv.getValues().isEmpty() ? null : cv.getValues().iterator().next();
} else {
indexValue = indexValueFactory.createIndexValue(value);
}
String geConstraint = String.format("{%s ", indexValue != null && indexValue.getValue() != null && !indexValue.getValue().isEmpty() ? indexValue.getValue() : DEFAULT);
constraint.addEncoded(POS, geConstraint);
}
use of org.apache.stanbol.entityhub.yard.solr.impl.SolrQueryFactory.ConstraintValue in project stanbol by apache.
the class GeEncoder method encode.
@Override
public void encode(EncodedConstraintParts constraint, Object value) {
IndexValue indexValue;
if (value == null) {
// default value
indexValue = null;
} else if (value instanceof IndexValue) {
indexValue = (IndexValue) value;
} else if (value instanceof ConstraintValue) {
ConstraintValue cv = (ConstraintValue) value;
indexValue = cv.getValues() == null || cv.getValues().isEmpty() ? null : cv.getValues().iterator().next();
} else {
indexValue = indexValueFactory.createIndexValue(value);
}
String geConstraint = String.format("[%s ", indexValue != null && indexValue.getValue() != null && !indexValue.getValue().isEmpty() ? indexValue.getValue() : DEFAULT);
constraint.addEncoded(POS, geConstraint);
}
use of org.apache.stanbol.entityhub.yard.solr.impl.SolrQueryFactory.ConstraintValue in project stanbol by apache.
the class LtEncoder method encode.
@Override
public void encode(EncodedConstraintParts constraint, Object value) {
Double boost = null;
IndexValue indexValue;
if (value == null) {
// default value
indexValue = null;
} else if (value instanceof IndexValue) {
indexValue = (IndexValue) value;
} else if (value instanceof ConstraintValue) {
ConstraintValue cv = (ConstraintValue) value;
indexValue = cv.getValues() == null || cv.getValues().isEmpty() ? null : cv.getValues().iterator().next();
boost = cv.getBoost();
} else {
indexValue = indexValueFactory.createIndexValue(value);
}
StringBuilder ltConstraint = new StringBuilder("TO ");
if (indexValue != null && indexValue.getValue() != null && !indexValue.getValue().isEmpty()) {
ltConstraint.append(indexValue.getValue());
} else {
ltConstraint.append(DEFAULT);
}
ltConstraint.append('}');
if (boost != null) {
ltConstraint.append("^").append(boost);
}
constraint.addEncoded(POS, ltConstraint.toString());
}
Aggregations