/**
* @param indexConstraint
* @param textConstraint
*/
private void initTextConstraint(IndexConstraint indexConstraint) {
TextConstraint textConstraint = (TextConstraint)indexConstraint.getConstraint();
ConstraintValue constraintValue = new ConstraintValue();
//init the boost
addBoost(constraintValue, textConstraint);
//init the Phrase Query based on the ProximityRanking state
if(textConstraint.isProximityRanking() != null){
constraintValue.setProperty(QueryConst.PHRASE_QUERY_STATE, textConstraint.isProximityRanking());
} else {
//TODO: maybe make the default configureable for the SolrYard
constraintValue.setProperty(QueryConst.PHRASE_QUERY_STATE, QueryConst.DEFAULT_PHRASE_QUERY_STATE);
}
for(String text : textConstraint.getTexts()){
constraintValue.getValues().add(indexValueFactory.createIndexValue(
valueFactory.createText(text)));
}
//use a index field for DataType, Languages and the Field
indexConstraint.setIndexFieldConstraints(
new IndexField(indexConstraint.getPath(),
IndexDataTypeEnum.TXT.getIndexType(),
textConstraint.getLanguages()));
//add the value for the constraint
switch (textConstraint.getPatternType()) {
case none:
indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue);
break;
case wildcard:
indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.WILDCARD, constraintValue);
break;
case regex:
indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.REGEX, constraintValue);
break;
default:
indexConstraint.setInvalid(String.format(
"PatterType %s not supported for Solr Index Queries!", textConstraint.getPatternType()));
}
}