Closed NullSoldier closed 8 years ago
The answer is incredibly simple, to use custom_search instead of search. That is located here, https://github.com/Sparrho/bungiesearch/blob/21cf0cf6e7a7e5c77b904f773f2c3b1cc173e14d/bungiesearch/managers.py#L26
Yes. Alternatively, you can also take a slice with the step
parameter set to True
, as follows:
lazy = Article.objects.search.query('match', _all='Description')
print len(lazy) # Prints the number of hits by only fetching the number of items.
for item in lazy[5:10:True]:
print item # Will print an ES Result object
I'm also just realizing that this functionality is not documented, although it is in the tests.
I want to prevent this query from executing, because I really just want raw results (id field mostly). https://github.com/Sparrho/bungiesearch/blob/master/bungiesearch/__init__.py#L185
The reason for this is that after I search ElasticSearch I need to perform more complex logic in our database with the ids before I can decide if they should be loaded from the database and loading all those models from is a performance cost when I may only actually end up wanting to materialize half of them.
Looking at the code, it's not exactly clear. I'll keep looking and close this if I figure out how.