I'm using the python client of django-elasticsearch and got a particularly weird error. Here is my setup:
I have an index named "information_documents" in ES, and I created an alias called "info" that contains this index only.
"information_documents": {
"aliases": {
"info": {}
}
}
I have a class "InfoDocument" defined in documents.py, and this is the type of the data I have in my ES database, from which I am searching. I now try to change the name in the index subclass from the index name("information_documents") to the alias name("info").
class InfoDocument(Document):
class Index:
# Name of the Elasticsearch index
name = 'info'
Doing that caused something weir for me, when I call:
from documents import InfoDocument
documents = InfoDocument.search()
for doc in documents:
#do something
doc.save()
Apparently when the name in InfoDocument.index is the index name, the type of doc is:
"documents.InfoDocument"
but when I change it to the alias name, the type is
"elasticserch_dsl.response.hit.Hit"
Therefore, it triggers error
"Object Hit has no attribute 'save'"
However, when I check the type of "documents", its type is consistently
"django_elasticsearch_dsl.search.Search"
Why would the iteration of objects of the same type resulting in two completely different types? I would really appreciate if someone could educate me on this.
Also this is my first time posting on stackoverflow so please also tell me if any part of my question could be improved! I'll be more than happy to fix it :)