-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
[#6089] Fix typeahead searches #6120
Conversation
It appears |
Exception message matching was first added in 22b2db4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense in principle!
Would be worth expanding the details into the commit message, and ideally link to the upstream code where these errors exist so that we have a better future reference.
It appears
QueryParserError
still exists in the Xapian so maybe we need to catch bothQueryParserError
andWildcardError
Yeah maybe they split these into two distinct concepts. We reference QueryParserError
elsewhere so I assume both still exist, but whether we need to rescue from both here IDK.
I could only replicate in production
I think it's worth trying to test this fix against the prod DB somehow. Worst case just temporarily patch the live file and run the query in the console.
Still defaults to 1000 expansions but this can now be overriden by adding a `config/xapian.yml` file or by calling `ActsAsXapian.max_wildcard_expansion = n` for example in a before spec callback hook.
d2ad899
to
99dc45b
Compare
@garethrees I've made some changes:
|
In trying to write a spec to show the original
|
In production we are hitting the wildcard expansion limit, which is currently set to 1000. We should consider increasing this limit. We can do this with 9d57051 by adding a
From my tests in the production Rails console, increasing to 1075 allows the wildcard query for 'Cabinet Office' to succeed. We would also need to consider server memory usage /cc @sagepe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Amazing work 🦸♂️
Couple of tiny changes suggested but no need for re-review.
Re-raise with are own exception class to allow us to handle gracefully downstream.
Use new ActsAsXapian exception instead of relying matching the exception message which has/may changed in the past/future. Adds a spec, using the new `max_wildcard_expansion` config to prove non-wildcard searches will happen.
It's unclear if this is a big problem or if we could mitigate failed wildcard searches by adjusting Xapian's max expansion limit. This is also changes the Rails logging level to warn.
99dc45b
to
0e0fe30
Compare
Relevant issue(s)
Fixes #6089
What does this do?
Update expected exception message when wildcard searches error allowing
fallback to an non-wildcard search to continue.
Why was this needed?
Poor search performance
Implementation notes
Locally in dev and test env all was working fine. I could only replicate in production, this is due to the size of the index. A large index can't always do a wildcard search, for example, when searching for
Cabinet Office
it will raise an exception with the message like:WildcardError: Wildcard office* expands to more than 1000 terms
This message seems to have changed at some point when upgrading Xapian in the past.