[SEARCH-1746] (#538)

Modified explicit sharding in order to use Int and Long types
This commit is contained in:
eliaporciani
2019-07-31 15:37:40 +02:00
committed by GitHub
parent 79ee4222e7
commit fb4c61c739
8 changed files with 169 additions and 136 deletions

View File

@@ -359,6 +359,8 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
if(enabled)
{
QName shardPropertQName = null;
QName shardPropertyType = null;
if(nodeParameters.getShardProperty() != null)
{
PropertyDefinition pdef = QueryParserUtils.matchPropertyDefinition(NamespaceService.CONTENT_MODEL_1_0_URI, namespaceService, dictionaryService, nodeParameters.getShardProperty());
@@ -366,14 +368,30 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
{
throw new AlfrescoRuntimeException("Invalid shard property: "+nodeParameters.getShardProperty());
}
if((!pdef.getDataType().getName().equals(DataTypeDefinition.TEXT)) && (!pdef.getDataType().getName().equals(DataTypeDefinition.DATE)) && (!pdef.getDataType().getName().equals(DataTypeDefinition.DATETIME)))
shardPropertyType = pdef.getDataType().getName();
final Set<QName> allowedShardKeyTypes = Set.of(
DataTypeDefinition.TEXT,
DataTypeDefinition.DATE,
DataTypeDefinition.INT,
DataTypeDefinition.LONG);
if (!shardPropertyType.equals(DataTypeDefinition.TEXT)
&& !shardPropertyType.equals(DataTypeDefinition.DATE)
&& !shardPropertyType.equals(DataTypeDefinition.DATETIME)
&& !shardPropertyType.equals(DataTypeDefinition.INT)
&& !shardPropertyType.equals(DataTypeDefinition.LONG))
{
throw new AlfrescoRuntimeException("Unsupported shard property type: "+(pdef.getDataType().getName() + " for " +nodeParameters.getShardProperty()));
}
shardPropertQName = pdef.getName();
}
List<Node> nodes = solrDAO.getNodes(nodeParameters, shardPropertQName);
List<Node> nodes = solrDAO.getNodes(nodeParameters, shardPropertQName, shardPropertyType);
for (Node node : nodes)
{
@@ -385,7 +403,6 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
}
callback.handleNode(node);
}
}