diff --git a/includes/class-tmdo-hivepress-entity-groups.php b/includes/class-tmdo-hivepress-entity-groups.php index 2894502..eed41ea 100644 --- a/includes/class-tmdo-hivepress-entity-groups.php +++ b/includes/class-tmdo-hivepress-entity-groups.php @@ -257,7 +257,16 @@ final class TMDO_HivePress_Entity_Groups { 'label' => 'Hourly rate', ), ), - array( 'post_types' => array( 'hp_listing' ) ) + array( + 'post_types' => array( 'hp_listing' ), + // Filtered and sorted on by HivePress search. Declared as indexes + // (added in place) rather than `searchable`, which would change + // the schema hash and rebuild a table that may hold aeav_only data. + 'indexes' => array( + 'hourly_rate' => array( 'hp_hourly_rate' ), + 'rating_count' => array( 'hp_rating_count' ), + ), + ) ); } /** diff --git a/tests/unit/HivePressEntityGroupsTest.php b/tests/unit/HivePressEntityGroupsTest.php index db610ce..6eea5f1 100644 --- a/tests/unit/HivePressEntityGroupsTest.php +++ b/tests/unit/HivePressEntityGroupsTest.php @@ -58,6 +58,21 @@ class HivePressEntityGroupsTest extends TestCase { } } + /** + * HivePress filters and sorts listings by these; they are declared as + * group indexes (added in place by core) rather than `searchable`, which + * would change the pinned hash and rebuild the table. + */ + public function test_listing_columns_filtered_and_sorted_on_are_indexed(): void { + $this->assertSame( + array( + 'hourly_rate' => array( 'hp_hourly_rate' ), + 'rating_count' => array( 'hp_rating_count' ), + ), + TMDO_Entity_Registry::get_group_indexes( 'post', 'hp_listing_core' ) + ); + } + public function test_shared_keys_keep_their_current_owner(): void { foreach ( self::SHARED_KEY_OWNERS as $key => $group ) { $this->assertSame( $group, TMDO_Entity_Registry::get_field( 'post', $key )['group'], $key );