Skip to content

SCC-5490: Update item location filter#772

Open
7emansell wants to merge 12 commits into
mainfrom
SCC-5490/item-location-filter
Open

SCC-5490: Update item location filter#772
7emansell wants to merge 12 commits into
mainfrom
SCC-5490/item-location-filter

Conversation

@7emansell

@7emansell 7emansell commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
  • Updates item location filter to use the buildingLocation calculated from the item's holding location ID
    • and then adds the corresponding labels using data/buildingLocations
  • Calculates the buildingLocation field to put on the Item for ease of display on the frontend (still need the inline script though since we're not indexing items with this)
  • Adds shortLabels to the data/buildingLocations since these strings don't seem to exist anywhere else. Still need full labels for other places on the frontend
  • Updates some tests... not sure if the responses should have changed so much but it seems to be unrelated to my changes?

supporting evidence:
Now ending up with item aggs that look like this:

 {
      "@type": "nypl:Aggregation",
      "@id": "res:location",
      "id": "location",
      "field": "location",
      "values": [
        {
          "value": "rc",
          "count": 3,
          "label": "Offsite"
        },
        {
          "value": "ma",
          "count": 1,
          "label": "Stephen A. Schwarzman Building"
        }
      ]
    },

@7emansell 7emansell changed the title Scc 5490/item location filter SCC-5490: Update item location filter Jul 10, 2026
@7emansell
7emansell marked this pull request as ready for review July 10, 2026 16:32
Comment thread lib/jsonld_serializers.js
}]
}
}
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

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.

ignore all the fixture updates sorry

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.

item format filter is being screwy on these not sure why

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd expect most of these to not change, should we investigate why updating some of the filter logic may have changed what is returned? Or is this a change to the underlying data?

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.

Went back and checked this specific bib on QA– item formats and counts did genuinely update, but updated to look for Book/text where previously I had just had Text

@mwbenowitz mwbenowitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall this looks good, just had a few questions!

Comment thread lib/resources.js Outdated
terms: {
size: 100,
script: {
source: "def locs = doc['items.holdingLocation.id']; if (locs.size() == 0) return null; def loc = locs.value; int colonIdx = loc.indexOf(':'); if (colonIdx == -1) return null; def locId = loc.substring(colonIdx + 1); if (locId.length() < 2) return null; def parentLoc = locId.substring(0, 2); if (['ma', 'pa', 'sc', 'rc', 'bu'].contains(parentLoc)) { return parentLoc; } return null;"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few questions about this script!

  • This instance and the one below seem substantially similar. Is there in value in refactoring them out to a const and then just changing the returns? Would make things a bit easier to maintain
  • Any performance concerns with executing such a complicated Painless script? I think there are other ways to achieve this but they might not be possible with how the index is currently configured.

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.

Moved out to util.js. There is a performance cost (doesn't have to compile every time but it's still slower than a native ES query), and yes wouldn't have to do this if we indexed the building location ID on the item. Decided on this approach since it'll be faster to get out than a full reindex but could put that approach on the docket for upcoming reindexes?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd expect most of these to not change, should we investigate why updating some of the filter logic may have changed what is returned? Or is this a change to the underlying data?

@7emansell
7emansell requested a review from mwbenowitz July 13, 2026 20:19
@7emansell

Copy link
Copy Markdown
Contributor Author

Not merging this into QA until status messaging work is closer to release (as is this will break the item location filters)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants