17

I am working on a search query which needs to do a geospatial filter (i.e. filter all elements outside of a certain radius). We have both PostgreSQL and ElasticSearch as part of our infrastructure and I am evaluating which of the two to use.

I'm not asking for "which is better", but an objective pros & cons list would be helpful, in terms of ease of implementation, performance, scalability, etc.

lmirosevic
  • 15,787
  • 13
  • 70
  • 116
  • I have been using Postgres/Postgis for years and am about to start testing some geocoding and fuzzy address matching with Lucene and Solr (which I have never used, but have seen a couple of very positive presentions on). I will let you know if I find anything that might be useful to you. What size datasets are you looking at and could you give a little more information on the kind of queries you might be running. – John Powell Apr 23 '14 at 15:09
  • @JohnBarça That would be great, please let me know if you find out something interesting. I'm interested in 2 types of queries (although very similar in nature): 1) get a set of results which are within a certain proximity in no particular order (i.e. a filter by proximity), and 2) return a set of results sorted by proximity, nearest first. – lmirosevic Apr 24 '14 at 15:31

1 Answers1

16

The postgis scales the same way as postgresql scales. The postgis index will work pretty the same as other relational, you may check it out here.

If you take a look at the link, it explains that it indexes using some geometrical algorithm which is performed on each insert operation, so it might not be responsive enough in real-time apps.

While elasticsearch have real time indexing, based on Lucene index. Elastic search generally suits better for realtime heavy applications, then Postgresql.

Postgresql has a huge advantage it is simplicity. It is much easier to implement test and maintain such a feature using Postgresql. For example, I prefer creating prototype based on Postgresql quickly, and if it starts perform bad because of big amount of writes, etc. I switch to elasticsearch implementation.

Slow Harry
  • 1,857
  • 3
  • 24
  • 42