0

Each user could save preferred queries. They want to be notified when one item that is the result of these queries is created or updated. A naive solution would be to execute each queries and check if the updated or created item is contained in the result. Is there a better way to perform this task ?

4
  • 1
    Why is the naive solution not good enough? What are your criteria that makes another solution better?
    – Rik D
    Apr 13 at 13:14
  • @RikD naive solution is not really scalable IMO because number of searches will grow with the number of users that use notifications (X searches per user per saved queries)
    – Woody
    Apr 13 at 13:29
  • 1
    Well it's an interesting question and I don't know if there's even another way to do it, let alone if the other way would be more scalable. Did you come up with other solutions yourself? Also, why exactly is this solution not scalable? Perhaps running all queries for all users when new items are created is the only way, in which case you could focus on making the working solution scalable instead of changing it.
    – Rik D
    Apr 13 at 13:58
  • Exactly @RikD, i also think that it is not an easy problem to solve. I was just wondering if someone else would think of a more elegant/scalable solution. The way i see it, there are 2 ways to do it, both with their benefits/disadvantages : 1) either perform search during updates and save relationships then send notifications whenever you need to ; 2) or perform search whenever notifications should be sent. 1) would be better if you have few updates and 2) preferable if you have lots of updates
    – Woody
    Apr 13 at 15:16
0

Elasticsearch provides functionality for this. See their documentation.

Briefly, you register your filter and specify how often you want to be notified. Then, when relevant indexing events occur, the clients can be notified. You can specify if you need the objects or some aggregations like sums.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.