Skip to content

Commit

Permalink
EZP-31325: Fixed sorting by Content & Location ID
Browse files Browse the repository at this point in the history
 * Indexed new normalized Solr Fields "content_id_normalized" and "location_id_normalized" as integers (*_i)

 * Aligned SortClause\ContentId and SortClause\Location\Id to use the new Fields.
  • Loading branch information
alongosz committed May 29, 2020
1 parent 9f44a81 commit 0a57b75
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/Query/Common/SortClauseVisitor/ContentId.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion lib/Query/Location/SortClauseVisitor/Location/Id.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 0a57b75

Please sign in to comment.