[Answer]-Realtime string matching results in Django

1👍

This is an ideal case for considering shifting to node.js, or some other asynchronous framework. Tornado is a good one if you want to stick to Python.

Also, I remember a friend using whoosh as a search engine for an internship project. He was fairly satisfied with it, so I can recommend it.

👤slider

0👍

You might want to preprocess the file.
Say make a cache while each word maps to the set of lines it contains so you can just fetch it and return them.

👤qihqi

0👍

You could get an initial request to kick off a thread to do the work of reading the file to a shared resource and return a 200 response immediately to the browser.

A Ajax poller on the client side can request periodically on a loop and pick up and display any new results in the resource until the file is read.

This is a quick and dirty approach and as @slider says an asynchronous framework is a better idea for long polling if your app relies on it a lot.

👤gonkan

Leave a comment