0

There is two spaces, named e.g. Company and Cars. Space Company has company id (primary index) and geolocation (point) fields (secondary index). Space Cars has car (primary index) and companies (array of all companies where this car can be rented). I need to get top 10 Companies in specified rectangle where specific car can be rented. What is the (if I can say so) best solution to achieving this?

Here I need to combine spatial and non-spatial indexes in order to get result. My search plan is to look for car tuple and get all companies (there may be 1000 of them), and then in another space to filter 10 of the within specified rectangle.

My use case is something similar to this (not rent-a-car use case), but all logic is same. There will be much more Companies than cars (millions of Companies and 300-500k of Cars). How to optimize my plan in order to get these infos, what indexes to use, etc.? There need to be spatial and non-spatial conditions for one select, as you see.

Community
  • 1
  • 1
Aleksandar
  • 1,163
  • 22
  • 41
  • 'top of 10 Companies in specified rectangle' - what is the 'top' criteria for the company? index? – Vasiliy Soshnikov May 05 '16 at 06:57
  • @VasiliySoshnikov Resulting set will have hundreds of results. Return 10-50 locations nearest to the center of the rectangle. – Aleksandar May 05 '16 at 12:10
  • To not duplicate the answer, here's a link that explains this: https://stackoverflow.com/a/63885927/13626536 –  Sep 14 '20 at 22:14

1 Answers1

0

I think the best strategy for this type of index would be to map your cars to points in another dimension, sufficiently far apart from each other. E.g. if your typical search is within a few square kilometers, make sure each car "coordinate" is at least a few dozen kilometers away from the nearest neighbour car. Then you can use our multi-dimensional RTREE index for the search.

Kostja
  • 1,607
  • 10
  • 17
  • If I understood well: This approach of mapping cars is not suitable because there is no way to make such a distance between them. Companies (and so cars) are very close to each other, max at few hundred meters, but may be tens of meters, too. Second, one car can be rented in hundreds of companies, so I don't get it how to add third dimension to the index. – Aleksandar May 05 '16 at 12:17