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
Add ability to declare Solr object with default commit policy #221
Conversation
@acdha you mind giving this a look over? |
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'm mixed on having the separate _get_commit
method - it looks like we could just let _update
do that check.
One other thing we should cover in the test case is having tests with commit=None/True/False using Mock to confirm the expected commit value is in the constructed URL.
.gitignore
Outdated
@@ -1,4 +1,6 @@ | |||
.tox | |||
solr*.tgz | |||
solr-app | |||
solr |
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.
This change is unrelated
pysolr.py
Outdated
@@ -898,11 +905,12 @@ def add(self, docs, boost=None, fieldUpdates=None, commit=True, softCommit=False | |||
m = force_unicode(m) | |||
|
|||
end_time = time.time() | |||
commit = self._get_commit(commit) |
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.
Do we really need to make this call here when it's just calling _update()
which does the same check? I'm thinking we could remove it in both _add
& _delete
and inline the _get_commit
check into _update
.
Thanks I will review this sometime tomorrow. |
Thanks for sending the request - it's a good idea but this has been a busy period at work for me to get around to OSS reviews. |
@acdha you were totally right about |
Can you rebase this against the current master branch & confirm that the tests still pass? |
README.rst
Outdated
|
||
# Setup a Solr instance. The trailing slash is optional. | ||
# All request to solr will result in a commit | ||
solr = pysolr.Solr('http://localhost:8983/solr/core_0/', search_handler='/autocomplete', commit_by_default=True) |
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.
Maybe this should be something like send_commits or something? by_default doesn't sound right to me.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
And this should not be closed either. Can't say I'm a fan of the stale bot. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Received all feedback as of PR#151 comment: <#151 (comment)> In particular, better idiomatic python code for the multiple id cases, and an improved test that will delete all documents except one, rather than deleting all in one go.
Rename commit_by_default to always_commit
Thanks for updating it. It looks good to me. The only question I had is whether we should default to |
I think we concluded that switching to
|
Oh, and I do feel pretty strongly about this, because always_commit=True is a weird default that'd definitely mess some people up. |
Fine by me |
Thanks folks 😄 When this goes out we probably want to make a note very explicitly in the changelog that the default commit policy is to not commit and if user's are upgrading to this version, they need to ensure that if they want to always commit that they change their constructor calls. |
@efagerberg if you want to draft that wording in a pull request it's a good idea. |
Since solr has hooks to auto commit after X documents or X seconds, it is best that the
Solr
methodsget
,delete
, and_update
do not have a policy of committing by default.One may already assume this to be false by default since it is good practice to limit commits. But incase users rely on this functionality, there is the ability to declare the default policy in the
Solr
constructor.