-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[FIXED] -- handle trailing slash in Solr index URL for core reload. #1968
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
base: master
Are you sure you want to change the base?
[FIXED] -- handle trailing slash in Solr index URL for core reload. #1968
Conversation
Good catch, @DhavalGojiya |
Is there any way to create a test that fails on the current code and proves that this change fixes that failure? |
To reproduce the issue, update HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://localhost:9001/solr/my_core/',
'TIMEOUT': 60 * 5,
'INCLUDE_SPELLING': True,
'BATCH_SIZE': 100,
'EXCLUDED_INDEXES': ['thirdpartyapp.search_indexes.BarIndex']
}
} Running the To fix this, remove the trailing slash from the URL: 'URL': 'http://localhost:9001/solr/my_core' My PR corrects this issue by handling URLs with or without a trailing slash. Attach: Image attached for the failure of this management command when there is slash at the end in URL |
Or it will be better if you record a video of test case and upload it here |
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.
Thanks! However test_haystack/solr_tests/test_solr_management_commands.py
should be completed with a regression test for this fix.
ea75a80
to
f050d86
Compare
Thank you for your response. I have rebased from the master branch and pushed again, so my previous commit is no longer present. I will try to add regression test case for this very soon. |
- When running `python manage.py build_solr_schema --reload_core=True`, it is crucial to correctly extract the Solr core name from the URL defined in the settings. - The existing implementation failed if the URL ended with a trailing slash, resulting in an empty core name due to the final slash being considered as a separator. Added test cases: - `test_build_solr_schema_reload_core_with_trailing_slash` - `test_build_solr_schema_reload_core_without_trailing_slash` These ensure that the core reload logic works correctly regardless of whether the Solr URL has a trailing slash.
34ea372
to
f0ff2c4
Compare
Seems good to me @DhavalGojiya |
python manage.py build_solr_schema --reload-core=True
, it is crucial to correctly extract the Solr core name from the URL defined in the settings.This splits the URL by the last / and takes the last part as the core name. If the URL ends with a slash, the result is an empty string and unable to reload core error will raised.