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

Use 'create' instead of 'index' to avoid stale data scenario #22

Open
jaddison opened this issue Oct 30, 2017 · 0 comments
Open

Use 'create' instead of 'index' to avoid stale data scenario #22

jaddison opened this issue Oct 30, 2017 · 0 comments

Comments

@jaddison
Copy link
Owner

Gleaned from the discussion with @avelis in #20, during the bulk reindexing scenario only the following line:

data = {'delete' if delete else 'index': data}

would likely be better as:

data = {'delete' if delete else 'create': data}

Even better, for flexibility, probably having a safe default parameter into bulk_index() makes sense, like:

def bulk_index(cls, es=None, index_name='', queryset=None, create_only=False):
  ...
  action = 'delete' if delete else ('create' if create_only else 'index')
  data = {action: data}

This would prevent any possible overwriting of data in the new index during the reindex process. That said, this would never happen given the current structure and usage of this library. It becomes more relevant in a parallel index writing strategy discussed in #20.

See ES bulk docs for more information.

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

No branches or pull requests

1 participant