-
Notifications
You must be signed in to change notification settings - Fork 0
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
Partial search #20
Partial search #20
Conversation
Up to now we only searched for exact matches, which was never the intention! With this change, searching for e.g. "water" will also return entries containing "waters" and "waterclock". Apparently this only works with text, not keyword fields (see https://stackoverflow.com/questions/46696190) but this covers all the fields we are searching for (we do have some keyword fields, but those are only used for sorting, not matching).
This restores the OR behaviour of searching for multiple words (see #17). It will be easy to change if we want to make AND the default behaviour.
The Elasticsearch client will be needed for tests of the search results, so it's easier if it's accessible to all test files. Same for the test glossary entries.
The setup of the test data could be improved, but that can be done as part of using an Elasticsearch plugin for pytest (see this comment in #6). I think this is ready for review now. |
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.
Approved with a minor suggestion.
# Also note that this fixture cannot be module-scoped because monkeypatch is | ||
# function-scoped. | ||
monkeypatch.setattr(ingest.bulk_upload, "INDEX_NAME", test_index_name) | ||
assert ingest.bulk_upload.INDEX_NAME == test_index_name # just making sure |
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.
It has taken me a little while and some StackOverflow research to feel OK about an assert being inside of a fixture.
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.
I've just tested it myself: a bad assertion in a fixture makes all tests that use it fail, before any code in those tests is run. I think it's safe enough to leave in!
Fixes #17, partially addresses #6.
This makes it so partial matches will be returned - for example, searching for
cat
will match bothcat
andcatch
(in any of the searched fields). As before, if a user searches for multiple words (separated by spaces), this will return results matching any of those words.Main parts: