diff --git a/search/src/main/scala/weco/api/search/models/Aggregation.scala b/search/src/main/scala/weco/api/search/models/Aggregation.scala index 304ac7c49..89590aff8 100644 --- a/search/src/main/scala/weco/api/search/models/Aggregation.scala +++ b/search/src/main/scala/weco/api/search/models/Aggregation.scala @@ -27,7 +27,7 @@ import scala.util.{Try} // } // } //} - +// // Each bucket then has the following format (the nested buckets are only included in 'labeled ID' aggregations): //{ // "key": "i", @@ -41,6 +41,7 @@ import scala.util.{Try} // ] // } //} +// For more information on why aggregations are structured this way, see the AggregationsBuilder class object AggregationMapping { import weco.json.JsonUtil._ private val globalAggBuckets = diff --git a/search/src/main/scala/weco/api/search/services/WorksAggregationsBuilder.scala b/search/src/main/scala/weco/api/search/services/WorksAggregationsBuilder.scala index 9533c6087..f53a93b7d 100644 --- a/search/src/main/scala/weco/api/search/services/WorksAggregationsBuilder.scala +++ b/search/src/main/scala/weco/api/search/services/WorksAggregationsBuilder.scala @@ -133,9 +133,9 @@ object WorksAggregationsBuilder case _: GenreIdFilter => List(WorkAggregationRequest.GenreId) case _: SubjectLabelFilter => List(WorkAggregationRequest.SubjectLabel) case _: SubjectIdFilter => List(WorkAggregationRequest.SubjectId) - case _: ContributorsIdFilter => - List(WorkAggregationRequest.ContributorLabel) case _: ContributorsLabelFilter => + List(WorkAggregationRequest.ContributorLabel) + case _: ContributorsIdFilter => List(WorkAggregationRequest.ContributorId) case _: LicenseFilter => List(WorkAggregationRequest.License) case _: AvailabilitiesFilter => diff --git a/search/src/test/scala/weco/api/search/images/ImagesFiltersTest.scala b/search/src/test/scala/weco/api/search/images/ImagesFiltersTest.scala index 504949db4..790b1a25c 100644 --- a/search/src/test/scala/weco/api/search/images/ImagesFiltersTest.scala +++ b/search/src/test/scala/weco/api/search/images/ImagesFiltersTest.scala @@ -133,7 +133,7 @@ class ImagesFiltersTest extends AnyFunSpec with ApiImagesTestBase { withGenreFilterRecords { routes => assertJsonResponse( routes, - path = s"$rootPath/images?source.genres.concepts=" + path = s"$rootPath/images?source.genres.id=" ) { Status.OK -> imagesListResponse( ids = Seq( @@ -150,7 +150,7 @@ class ImagesFiltersTest extends AnyFunSpec with ApiImagesTestBase { withGenreFilterRecords { routes => assertJsonResponse( routes, - path = s"$rootPath/images?source.genres.concepts=baadf00d" + path = s"$rootPath/images?source.genres.id=baadf00d" ) { Status.OK -> imagesListResponse( ids = Seq( @@ -167,7 +167,7 @@ class ImagesFiltersTest extends AnyFunSpec with ApiImagesTestBase { withGenreFilterRecords { routes => assertJsonResponse( routes, - path = s"$rootPath/images?source.genres.concepts=g00dcafe,baadf00d" + path = s"$rootPath/images?source.genres.id=g00dcafe,baadf00d" ) { Status.OK -> imagesListResponse( ids = Seq( diff --git a/search/src/test/scala/weco/api/search/services/AggregationsBuilderTest.scala b/search/src/test/scala/weco/api/search/services/AggregationsBuilderTest.scala index e02f80b87..6d5406ee3 100644 --- a/search/src/test/scala/weco/api/search/services/AggregationsBuilderTest.scala +++ b/search/src/test/scala/weco/api/search/services/AggregationsBuilderTest.scala @@ -35,9 +35,7 @@ class AggregationsBuilderTest unfilteredSelfTerms: Option[TermsAggregation] ) - // -> FilterAggregation -> FilterAggregation ("filtered") -> NestedAggregation ("nested") -> TermsAggregation -> TermsAggregation - // -> SelfNestedAggregation ("nestedSelf") -> TermsAggregation -> TermsAggregation - // -> SelfNestedAggregation ("nestedSelf") -> TermsAggregation -> TermsAggregation + // See AggregationsBuilder class for an explanation of why aggregations are structured this way private def decomposeRootAggregation(rootAggregation: FilterAggregation): DecomposedAggregation = { val filteredAggregation = rootAggregation.subaggs.head.asInstanceOf[FilterAggregation] val filteredNestedAggregation = filteredAggregation.subaggs.head.asInstanceOf[NestedAggregation] diff --git a/search/src/test/scala/weco/api/search/works/WorksFiltersTest.scala b/search/src/test/scala/weco/api/search/works/WorksFiltersTest.scala index aa89375b0..0a2774363 100644 --- a/search/src/test/scala/weco/api/search/works/WorksFiltersTest.scala +++ b/search/src/test/scala/weco/api/search/works/WorksFiltersTest.scala @@ -168,7 +168,7 @@ class WorksFiltersTest withGenreIdFilterRecords { routes => assertJsonResponse( routes, - path = s"$rootPath/works?genres.concepts=" + path = s"$rootPath/works?genres.id=" ) { Status.OK -> worksListResponse( ids = Seq( @@ -188,7 +188,7 @@ class WorksFiltersTest withGenreIdFilterRecords { routes => assertJsonResponse( routes, - path = s"$rootPath/works?genres.concepts=baadf00d" + path = s"$rootPath/works?genres.id=baadf00d" ) { Status.OK -> worksListResponse( ids = Seq( @@ -206,7 +206,7 @@ class WorksFiltersTest withGenreIdFilterRecords { routes => assertJsonResponse( routes, - path = s"$rootPath/works?genres.concepts=g00dcafe,baadf00d" + path = s"$rootPath/works?genres.id=g00dcafe,baadf00d" ) { Status.OK -> worksListResponse( ids = Seq(