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

Drop solr451 #1648

Merged
merged 7 commits into from
Jan 12, 2023
Merged

Drop solr451 #1648

merged 7 commits into from
Jan 12, 2023

Conversation

Bomme
Copy link
Contributor

@Bomme Bomme commented Jan 11, 2023

Issue(s)
#1083

Description
bring changes that remove Solr4 from #1614 to a separate PR.

Deployment steps:

@Bomme Bomme requested a review from alastair January 11, 2023 20:52
@alastair
Copy link
Member

The failing tests are because of a change in the exception that gets raised in the case of a connection error.

In current freesound, almost all operations that connect to solr have a try/except/pass block:

freesound/forum/models.py

Lines 180 to 184 in 417f641

instance.refresh_from_db()
try:
get_search_engine().add_forum_posts_to_index(instance.post_set.all())
except SearchEngineException:
pass

In fact, when running tests these exceptions have always been raised, as we have no way of disabling index-to-solr during tests. It was just luck that the solr 451 custom backend raised a SearchEngineException which allowed us to skip any potential exceptions while running tests.

It seems that tests were running with the solr451 backend, rather than the solr5 pysolr backend.

Now with pysolr, the pysolr. SolrError exception isn't getting caught and converted into a SearchEngineException.

The easiest immediate fix for this to get us back to where we were would be to correctly catch SolrError and re-throw it as a SearchEngineException. In the long-term we should decide if we want to run solr during tests or not.

The two classes that were remaining in solr451custom were common utils
for use in the solr backend, so rename the file to better reflect its
purpose instead of copying the definitions in to the solr backend.

Remove the custom SolrQueryPySolr class, as this was only needed to
separate it from the custom backend, which is no longer used.
Rename the as_dict method to as_kwargs to better reflect its purpose.
This class reimplemented the behaviour of the doseq=True parameter,
converting {"a", [1,2]} into &a=1&a=2
This syntax was previously used in the custom solr backend, but since we
started using pysolr we now use the to_kwargs method to serialise the
parameters in the SolrQuery object
Copy link
Member

@alastair alastair left a comment

Choose a reason for hiding this comment

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

Tests pass, and I was able to run this code and get search results. looks good, thanks!

@alastair alastair merged commit dd70e73 into master Jan 12, 2023
@alastair alastair deleted the drop_solr451 branch January 12, 2023 16:24
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