Skip to content
Open
2 changes: 1 addition & 1 deletion config/qa.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ENCRYPTED_ELASTICSEARCH_URI=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJYwgZMGCSqGSIb3DQEHBqCBhTCBggIBADB9BgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMIkDoQ9C/cCDCAq1wIBEIBQ+L3OgUGeOW9rs1CWkhpBjwM4LbbVRFIWedqew4UXIeSNMJ8cO9SNe4YGCUIoKwCDYt7W7ip3VtDRRRMVvz6QJw+Eg8ugTMVs2pbNFGNvaAQ=

RESOURCES_INDEX=resources-qa-2026-06-17
RESOURCES_INDEX=resources-qa-2026-07-14
BROWSE_INDEX=browse-qa-2026-01-15
ENCRYPTED_ELASTICSEARCH_API_KEY=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJ4wgZsGCSqGSIb3DQEHBqCBjTCBigIBADCBhAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAx+kryf2KUmGdBYD9sCARCAV3ygz3eXIdq8JX/wpG9JRWlTNMRcpNE1qT0zNlN4t+ZvXEoedLQa/3p1YjgHw06GIAdA9xtkMV4eH9a1K8uCvjP8XxxNKekcMj59TlResnu9QF3r7pGXuQ==

Expand Down
2 changes: 1 addition & 1 deletion data/buildingLocations.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{ "value": "ma", "label": "Stephen A. Schwarzman Building (SASB)","nickname": "SASB" }, { "value": "pa", "label": "The New York Public Library for the Performing Arts (LPA)","nickname": "LPA" },{ "value": "sc", "label": "Schomburg Center for Research in Black Culture","nickname": "Schomburg" },{ "value": "rc", "label": "Offsite - request in advance"},{ "value": "bu", "label": "Stavros Niarchos Foundation Library (SNFL)", "nickname": "SNFL" }]
[{ "value": "ma", "label": "Stephen A. Schwarzman Building (SASB)", "shortLabel": "Stephen A. Schwarzman Building", "nickname": "SASB" }, { "value": "pa", "shortLabel": "The New York Public Library for the Performing Arts", "label": "The New York Public Library for the Performing Arts (LPA)","nickname": "LPA" },{ "value": "sc", "label": "Schomburg Center for Research in Black Culture", "shortLabel": "Schomburg Center for Research in Black Culture", "nickname": "Schomburg" },{ "value": "rc", "label": "Offsite - request in advance", "shortLabel": "Offsite"},{ "value": "bu", "label": "Stavros Niarchos Foundation Library (SNFL)", "shortLabel": "Stavros Niarchos Foundation Library", "nickname": "SNFL" }]
2 changes: 1 addition & 1 deletion lib/elasticsearch/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const AGGREGATIONS_SPEC = {
}

const ITEM_FILTER_AGGREGATIONS = {
item_location: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.holdingLocation_packed' } } } },
item_location: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.buildingLocationId' } } } },
item_status: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.status_packed' } } } },
item_format: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.formatLiteral' } } } }
}
Expand Down
2 changes: 1 addition & 1 deletion lib/elasticsearch/elastic-query-filter-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const itemsFilterContext = (options) => {
location: (locations) => {
return {
terms: {
'items.holdingLocation.id': locations
'items.buildingLocationId': locations
}
}
},
Expand Down
26 changes: 26 additions & 0 deletions lib/jsonld_serializers.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ ResourceSerializer.formatItemFilterAggregations = function (aggregations) {
// If it's a packed value, parse out the value and label:
if (value.split('||').length === 2) {
;[value, label] = value.split('||')
// For item location, add the buildingLocation label
} else if (field === 'location') {
const loc = buildingLocations.find(l => l.value === value)
if (loc) {
label = loc.shortLabel
}
}
return {
value,
Expand Down Expand Up @@ -380,6 +386,11 @@ class ItemResourceSerializer extends JsonLdItemSerializer {
stmts.holdingLocation = ItemResourceSerializer.getFormattedHoldingLocation(this.body.holdingLocation)
}

const buildingLocation = ItemResourceSerializer.getBuildingLocation(this.body.holdingLocation)
if (buildingLocation) {
stmts.buildingLocation = buildingLocation
}

if (this.body.collectionId) {
stmts.collection = ResourceSerializer.getFormattedCollections(this.body.collectionId)
delete stmts.collectionId
Expand Down Expand Up @@ -411,6 +422,21 @@ class ItemResourceSerializer extends JsonLdItemSerializer {
}]
}

static getBuildingLocation (location) {
const loc = Array.isArray(location) ? location[0] : location
const parentLoc = loc?.['@id']?.split(':')[1]?.substring(0, 2)
if (parentLoc) {
const building = buildingLocations.find(l => l.value === parentLoc)
if (building) {
return [{
'@id': building.value,
prefLabel: building.shortLabel
}]
}
}
return null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since buildingLocation is calculated from holdingLocation, partner items will continue to return nothing for both. This case is already accounted for on the frontend

}

// Given an item, returns item with an added `identifier`
// of form 'urn:[sourceIdentifierPrefix]:[sourceIdentifier]'
// e.g.
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/elastic-body-builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('bodyForFindByUri', function () {
_nested: {
terms: {
size: 100,
field: 'items.holdingLocation_packed'
field: 'items.buildingLocationId'
}
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@ describe('bodyForFindByUri', function () {
_nested: {
terms: {
size: 100,
field: 'items.holdingLocation_packed'
field: 'items.buildingLocationId'
}
}
}
Expand Down
Loading
Loading