Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCC-4348: callnumber= and standard_number= param #420

Merged
merged 5 commits into from
Nov 25, 2024

Conversation

nonword
Copy link
Member

@nonword nonword commented Nov 18, 2024

Add support for callnumber= and standard_number= params (for use in Adv Search).

Removes use of gatherParams util in lib/routes because it was redundant given that each controller was also explicitly parsing specific params from the query string. We should now only need to define params once.

Changed how adv-search params are incorporated into the greater query (specifically for title=, contributor=, and subject=). Previously, due to an oversight, we only included the multi-match query associated with each of these params. With this update, we include the whole relevant search-scope query, including boosting. This means that all of the boosting applied to seach-scope queries is also applied to namesake adv-search queries (i.e. search_scope=title&q=foo should return the same results as title=foo, search_scope=contributor&q=bar should return the same results as contributor=bar and title=foo&contribotor=bar should return results that are boosted by the combination of boosting and must clauses used in both, likely returning narrower results)

https://newyorkpubliclibrary.atlassian.net/browse/SCC-4348

Copy link
Contributor

Choose a reason for hiding this comment

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

so glad to see the gatherParams situation refactored.

// We're specifically interested in params that match supported search-
// scopes because we can build a whole ES query just using the existing
// logic for that search scope:
if (this.request.advancedSearchParamsThatAreAlsoScopes()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what are the advanced search params that are not also scopes? is that just filters?

Copy link
Contributor

Choose a reason for hiding this comment

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

I realize this is older work, but I think this method wants a different name. It's not the search_scopeness of the params we're interested in, but rather that they're valid single value query params (as opposed to a compound q=spaghetti&search_scope=title format). the method itself isn't actually verifying that they are also search scopes, just that they are in the approved array of advanced search params.

Copy link
Member Author

Choose a reason for hiding this comment

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

The word "advanced" in "advanced search params" is just a reminder that this is for supporting params used in RC Adv Search, but actually there are many params besides q= that are not filters. For example isbn=, issn=. In the future there could be more. The fact that these params are also valid search_scope values is actually important because we're leveraging the existing search-scope logic to build the sub-query. We very much want each of the adv search params to individually work the same as the namesake search scopes do, so we do want to use the same logic. The method thus does verify that they are also search-scopes (recent update here). In the future, there may be other Adv Search params (e.g. 'ISBN'), which would be included in an "approved array of advanced search params" but wold not have a namesake search-scope. To support that, we would have to add custom handler code to add the extra clauses for that new adv-search param. The fact that all non-filter adv search params happen to have equivalent search-scopes right now is a convenience, but not one we assume will remain, hence the awkward function name.

.forEach((advSearchParam) => {
const advSearchValue = this.request.params[advSearchParam]
// Build a new ApiRequest object for this search-scope:
const request = ApiRequest.fromParams({
Copy link
Contributor

Choose a reason for hiding this comment

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

is this pattern being used elsewhere? something about it makes me uneasy...

Copy link
Member Author

Choose a reason for hiding this comment

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

Because ApiRequest feels like something that should only ever wrap a real user-initiated API request? It's a light-weight model representing a user query. The Adv Search page essentially allows you to find the intersection of multiple queries, so I think it's fine, but can you say more about what is unsettling? Conceptually we do want the same query to be generated from q=foo&search_scope=title as is generated from title=foo, so the two routes need to ultimately share some code. Do you see a clearer way?

@charmingduchess charmingduchess self-requested a review November 21, 2024 16:46
@nonword nonword merged commit 9222047 into main Nov 25, 2024
4 checks passed
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.

2 participants