diff --git a/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php b/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php index adff8add9..7c3d5a804 100644 --- a/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php +++ b/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php @@ -87,6 +87,12 @@ public function mapFields(Content $content) $contentInfo->id, new FieldType\IdentifierField() ), + // explicit integer representation to allow sorting + new Field( + 'content_id_normalized', + $contentInfo->id, + new FieldType\IntegerField() + ), new Field( 'content_type_id', $contentInfo->contentTypeId, diff --git a/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php b/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php index 19610e837..200ebf88e 100644 --- a/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php +++ b/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php @@ -48,6 +48,12 @@ public function mapFields(Location $location) $location->id, new FieldType\IdentifierField() ), + // explicit integer representation to allow sorting + new Field( + 'location_id_normalized', + $location->id, + new FieldType\IntegerField() + ), new Field( 'document_type', DocumentMapper::DOCUMENT_TYPE_IDENTIFIER_LOCATION, diff --git a/lib/Query/Common/SortClauseVisitor/ContentId.php b/lib/Query/Common/SortClauseVisitor/ContentId.php index 9e862f311..ef244d8d4 100644 --- a/lib/Query/Common/SortClauseVisitor/ContentId.php +++ b/lib/Query/Common/SortClauseVisitor/ContentId.php @@ -39,6 +39,6 @@ public function canVisit(SortClause $sortClause) */ public function visit(SortClause $sortClause) { - return 'content_id_id' . $this->getDirection($sortClause); + return 'content_id_normalized_i' . $this->getDirection($sortClause); } } diff --git a/lib/Query/Location/SortClauseVisitor/Location/Id.php b/lib/Query/Location/SortClauseVisitor/Location/Id.php index 0c004d214..3296622f5 100644 --- a/lib/Query/Location/SortClauseVisitor/Location/Id.php +++ b/lib/Query/Location/SortClauseVisitor/Location/Id.php @@ -39,6 +39,6 @@ public function canVisit(SortClause $sortClause) */ public function visit(SortClause $sortClause) { - return 'location_id' . $this->getDirection($sortClause); + return 'location_id_normalized_i' . $this->getDirection($sortClause); } }