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

Delete issue- appear at /_search but not at /123 #75

Open
yarnball opened this issue Jun 10, 2017 · 2 comments
Open

Delete issue- appear at /_search but not at /123 #75

yarnball opened this issue Jun 10, 2017 · 2 comments

Comments

@yarnball
Copy link

Hi,

ES and django seem to work fine except for deleting items. When delete an item, I can no longer access it via it's pk (eg localhost:9200/django/model-X/123). It returns "false".

However, it still appears at localhost:9200/django/model-X/_search. The hits total do not change when I delete an item.

Is there a particular way to remove items form the _search that is different from accessing them at their individual URL?

@lauxley
Copy link
Contributor

lauxley commented Jun 12, 2017

Hello,
in Elasticsearch, when you issue an Index, Update or Delete command, you have to wait until the next refresh for the changes to be available, do you still have the issue after manually refreshing the index ?
MyModel.es.do_update()

@yarnball
Copy link
Author

Ok thanks, i've done your suggestion. I'm calling it in models.py. Let me know if there's anything wrong with it:

class Test(EsIndexable, models.Model):
    title = models.CharField("Title", max_length=10000, blank=True)
    created = models.DateTimeField("Created", auto_now=False)
    updated = models.DateTimeField(auto_now=False)

    class Elasticsearch(EsIndexable.Elasticsearch):
        serializer_class = TestEsSerializer
        fields = ['title', 'created', 'updated']

@receiver(post_save, sender= Test)
@receiver(post_delete, sender= Test)
def index_test(instance, **kwargs):
    Test.es.do_update()

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

2 participants