pythondjangoelasticsearchwhoosh

Storing elasticsearch query result in Django session


I am currently in a development team that has implemented a search app using Flask-WhooshAlchemy. Admittedly, we did not think this completely through.

The greatest problem we face is being unable to store query results into a Flask session without serializing the data set first. The '__QueryObject' being returned via Whoosh can be JSON serialized using Marshmallow. We have gone through this route and, yes, we are able to store and manipulate the retrieved data, but at a tradeoff: initial searches will take a very long time (at least 30 seconds for larger result sets, due to serialization). For the time being, we are currently stuck with having to re-query anytime there are changes to the data set (changes that shouldn't require a fresh search, such as switching between result views and changing the number of results per page). Adding insult to injury, whoosh is probably not scalable for our purposes; Elasticsearch seems a better contender.

In short:

How can we store elasticsearch query results in a Django session so that we may be able to manipulate these results?

Any other guidance will be greatly appreciated.


Solution

  • If anyone cares, we finally got everything up and running and yes, it is possible to store elasticsearch query results in a Django session.