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

QA2 - ES relevance improvements and query generation refactor #411

Merged
merged 56 commits into from
Oct 21, 2024

Conversation

nonword
Copy link
Member

@nonword nonword commented Oct 11, 2024

This is a large PR. It includes two major efforts:

  1. Updated ES queries for the new v8 index
  2. Refactor how search queries are built

If you want to see the result of the first effort, this diff shows just the parts that are mainly about updating the client to work with the v8 index, adding an assessment script, and doing a rough implementation of the updated queries.

This PR builds on top of that first effort to also attempt to clarify search query generation. It adds simple tools for query construction so that the important decisions about matching are foregrounded, with the fiddly ES query generation happening in the background. The aim is to make it much clearer what matches are active for a given query and scope and make it clear how to change things.

Also: This includes a new buildingLocation agg and support for filters[buildingLocation]=...

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

nonword added 30 commits May 30, 2024 10:17
Incorporate latest queries from Mike.
Also stubs in some keyword matching for standard_number searches
Also add relevance report to debug response
 - named queries
 - min_should_match
 - more targetted standard_numbers searches
 - include some contrib matchers in 'all' search
Copy link
Contributor

@charmingduchess charmingduchess left a comment

Choose a reason for hiding this comment

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

Tremendous work! Most of my comments are just for clarification and some comments/documentation requests. I'm excited about the elastic search request encapsulation in particular.

config/production.env Outdated Show resolved Hide resolved
lib/api-request.js Outdated Show resolved Hide resolved
lib/availability_resolver.js Outdated Show resolved Hide resolved
lib/elasticsearch/config.js Show resolved Hide resolved
fields: null
},
standard_number: {
fields: null
Copy link
Contributor

Choose a reason for hiding this comment

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

why are these fields null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Historically, all search-scopes were configured in this const - with an array of fields to use in the query_string/multi-match query. With ES search improvements, two of these search-scopes don't use multi-match at all, so there's no need for a central config. However, this const remains a central, authoritative config for what search-scopes are available. I think future refactoring may change this, but for now I've just removed the fields prop from these search-scopes and added a comment to clarify

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for backfilling this documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

These are great and actually go a long way in documenting how we're using ES. 🤘🏻

test/elasticsearch-utils.test.js Show resolved Hide resolved
test/resources.test.js Show resolved Hide resolved
test/resources.test.js Show resolved Hide resolved
Updates:
 - Add search_scope=journal_title (to ease testing and because it really ought
   to be implemented in the discovery-api, not the front-end
 - Match on shelfmark lowercased
 - Allow smart-quotes in fully-quoted searches
 - Remove boost=1 on quoted creator/contrib phrase matching
 - Match on new idIsbn.clean and idIssn.clean (added 2024-10-17)
 - Updates qa index to 2024-10-16 (added shelfMark.keywordLowercased)
/**
* Examine request for user-filters. When found, add them to query.
*/
applyFilters () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this method be broken down any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree it should be, but this specific code is unchanged from previous form (just moved). So I'd like to keep that as a project for a future refactor if that's alright.

@nonword nonword mentioned this pull request Oct 17, 2024
@nonword nonword merged commit 15409b3 into main Oct 21, 2024
4 checks passed
@nonword nonword deleted the qa2-refactor branch October 21, 2024 16:15
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