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

Add ability to declare Solr object with default commit policy #221

Merged
merged 7 commits into from Sep 5, 2018
Merged

Add ability to declare Solr object with default commit policy #221

merged 7 commits into from Sep 5, 2018

Conversation

efagerberg
Copy link
Contributor

@efagerberg efagerberg commented Jul 17, 2017

Since solr has hooks to auto commit after X documents or X seconds, it is best that the Solr methods get, 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.

@efagerberg
Copy link
Contributor Author

@acdha you mind giving this a look over?

Copy link
Collaborator

@acdha acdha left a 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
Copy link
Collaborator

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)
Copy link
Collaborator

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.

@efagerberg
Copy link
Contributor Author

Thanks I will review this sometime tomorrow.

@acdha
Copy link
Collaborator

acdha commented Jul 19, 2017

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.

@efagerberg
Copy link
Contributor Author

@acdha you were totally right about _get_commit. Fixed that up and added a those tests.

acdha
acdha previously approved these changes Jan 9, 2018
@acdha
Copy link
Collaborator

acdha commented Jan 9, 2018

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)
Copy link
Contributor

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.

@efagerberg
Copy link
Contributor Author

@acdha sorry about the wait on this, rebased onto master. @mlissner I have changed the parameter name to always_commit is that more appropriate?

@stale
Copy link

stale bot commented Jun 5, 2018

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.

@stale stale bot added the stale label Jun 5, 2018
@mlissner
Copy link
Contributor

mlissner commented Jun 5, 2018

And this should not be closed either. Can't say I'm a fan of the stale bot.

@stale stale bot removed the stale label Jun 5, 2018
@stale
Copy link

stale bot commented Sep 3, 2018

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.

Cosimo Streppone and others added 7 commits September 3, 2018 16:16
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
@efagerberg
Copy link
Contributor Author

@acdha and @mlissner I have updated this branch to master, I hope this still has a chance to be considered as a contribution to this project.

@acdha
Copy link
Collaborator

acdha commented Sep 5, 2018

Thanks for updating it. It looks good to me. The only question I had is whether we should default to always_commit=True for backwards-compatibility on the assumption that people who aren't pressed on are less likely to read the documentation but I don't feel especially strongly about it.

@mlissner
Copy link
Contributor

mlissner commented Sep 5, 2018

I think we concluded that switching to always_commit=False was better because it:

  • would be a good thing for most people, who don't realize that commits should be infrequent in Solr.
  • would be a good reason to do a major version bump
  • should have minimal impact because of Solr's default commit policy (which regularly does commits)

@mlissner
Copy link
Contributor

mlissner commented Sep 5, 2018

Oh, and I do feel pretty strongly about this, because always_commit=True is a weird default that'd definitely mess some people up.

@acdha
Copy link
Collaborator

acdha commented Sep 5, 2018

Fine by me

@acdha acdha merged commit d0d482b into django-haystack:master Sep 5, 2018
@efagerberg
Copy link
Contributor Author

efagerberg commented Sep 6, 2018

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.

@acdha
Copy link
Collaborator

acdha commented Sep 6, 2018

@efagerberg if you want to draft that wording in a pull request it's a good idea.

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.

None yet

3 participants