When I run the following:
search_doc = Document.search(
using=client,
index=custom_index
)
search_doc = search_doc.query("term", doc_field = f"string_{num}")
and then use .scan()
I get Hit
objects. So, something seems to be wrong...
However, when I use the ids of those hit objects:
all_docs = [doc.meta.id for doc in search_doc.scan()]
for id in all_docs:
loc = Document.get(
using=client,
index=custom_index,
id = id
)
assert isinstance(doc, Document) # <- always true!!
Why is there this difference? Why doesn't the search object return documents objects?
Here's the definition of my Document class:
field_1 = dsl.Keyword()
field_2 = dsl.Keyword(multi=True)
data = dsl.Object(Inner_Document) # data will have many other fields
last_updated = dsl.Date()
class Index:
name = default_index # different from custom_index
settings = {
"number_of_shards": 1
}
class Meta:
dynamic = dsl.MetaField('strict')
The version of ES that I'm using is 7.17.6
.
The package elasticsearch
is 7.17.3
and elasticsearch
-dsl is 7.4.0
.
P.S: I'm regretting more and more having to use the elasticsearch_dsl python client more and more... No one in stackoverflow is able to help us, the docs of the package lack some details, and the git hub issue section is in a coma... no replies.
I'm not sure what ES company thinks of python, but I would have thought that a language like python would deserve a bit more dev support... Whenever I have a question directed a bit more to the python client side of things, I can almost give up of trying to find info... Sorry for this rant, but I'm just a bit tired.