11 Applications of nearest neighbor search

 

This chapter covers

  • Adapting abstract algorithms to the complexity of real systems
  • Designing a solution for the “closest hub” problem using NN search
  • Adding filtering to NN search to support business logic and dynamic supply
  • Dealing with faulty networks and failure, and deploying to the real world
  • Applying NN search to other domains, such as physics and computer graphics

It’s time to harvest what we’ve sown and to start solving the problems we have discussed in the last few chapters. As always, after a deep dive into theory, we try to give you a “real-life” angle, and in this chapter, we will incrementally build a solution for the “closest hub” problem, one that takes into account many of the issues a real application would face. But make no mistake—we can’t tackle all the possible issues here, and this chapter doesn’t aim to be an exhaustive description of all the possible problems you could face; neither it is a runbook about how to operate your e-commerce application. Only practice, rolling up your sleeves, and getting burned while trying can teach you that. What you can find in this chapter, besides a few examples of real-world technical challenges, is a hands-on example of the analysis process that brings you from a solution “on paper” for your use case, to a working application coping with the complex facets of reality.

11.1 An application: Find nearest hub

11.1.1 Sketching a solution

11.1.2 Trouble in paradise

11.2 Centralized application

11.2.1 Filtering points

11.2.2 Complex decisions

11.3 Moving to a distributed application

11.3.1 Issues handling HTTP communication

11.3.2 Keeping the inventory in sync

11.3.3 Lessons learned

11.4 Other applications

11.4.1 Color reduction

11.4.2 Particle interaction

11.4.3  Multidimensional DB queries optimization

11.4.4 Clustering

Summary