SEARCH-2296: Add new "_unit_of_time_quarter" date part field. (#267)

This commit is contained in:
Angel Borroy
2020-06-16 10:22:45 +02:00
committed by GitHub
parent 0a15ea6a45
commit 7e2ef6e994
3 changed files with 21 additions and 0 deletions

View File

@@ -191,6 +191,8 @@ public interface QueryConstants
public static final String FIELD_SOLR_UNIT_OF_TIME_MONTH_SUFFIX = "_unit_of_time_month";
public static final String FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX = "_unit_of_time_quarter";
public static final String FIELD_SOLR_UNIT_OF_TIME_YEAR_SUFFIX = "_unit_of_time_year";
public static final String FIELD_SITE = "SITE";

View File

@@ -409,6 +409,11 @@ public class QueryParserUtils implements QueryConstants
propertyFieldName = field.substring(field.startsWith("@") ? 1 : 0, field.length() - FIELD_SOLR_UNIT_OF_TIME_MONTH_SUFFIX.length());
ending = FIELD_SOLR_UNIT_OF_TIME_MONTH_SUFFIX;
}
else if (field.endsWith(FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX))
{
propertyFieldName = field.substring(field.startsWith("@") ? 1 : 0, field.length() - FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX.length());
ending = FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX;
}
else if (field.endsWith(FIELD_SOLR_UNIT_OF_TIME_YEAR_SUFFIX))
{
propertyFieldName = field.substring(field.startsWith("@") ? 1 : 0, field.length() - FIELD_SOLR_UNIT_OF_TIME_YEAR_SUFFIX.length());

View File

@@ -566,6 +566,20 @@ public class AlfrescoFunctionEvaluationContext implements FunctionEvaluationCont
return propertyField;
}
}
else if(field.endsWith(QueryConstants.FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX))
{
QName propertyField = QName.createQName(field.substring(0, field.length() - QueryConstants.FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX.length()));
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyField);
if (!propertyDef.getDataType().getName().equals(DataTypeDefinition.DATE) &&
!propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
{
throw new FTSQueryException(QueryConstants.FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX+" only supported on date and datetime properties");
}
else
{
return propertyField;
}
}
else if(field.endsWith(QueryConstants.FIELD_SOLR_UNIT_OF_TIME_YEAR_SUFFIX))
{
QName propertyField = QName.createQName(field.substring(0, field.length() - QueryConstants.FIELD_SOLR_UNIT_OF_TIME_YEAR_SUFFIX.length()));