5

I'm using CouchDB and GeoCouch and I'm trying to understand if it were possible to build a geospatial index and "query" the database both by using a location and a value from another field.

Data

{
   "_id": "1",
   "profession": "medic",
   "location": [15.12, 30.22]
}

{
   "_id": "2",
   "profession": "secretary",
   "location": [15.12, 30.22]
}

{
   "_id": "3",
   "profession": "clown",
   "location": [27.12, 2.2]
}

Questions

Is there any way to perform the following queries on these documents:

  • Find all documents with job = "medic" near location [15.12, 30.22] (more important)
  • List all the different professions near this location [15.12, 30.22] (a plus)

In case that's not possible, what options do I have? I'm already considering switching to MongoDB, but I'd rather solve in a different way.

Notes

  • Data changes quickly, new documents might be added and many might be removed

References

Faceted search with geo-index using CouchDB

Community
  • 1
  • 1
Dexter
  • 2,482
  • 27
  • 40
  • 1
    Have you considered using _list functions to handle filtering like this? I'm not experienced with Geocouch, so I can't speak any further on how to use it specifically. – Dominic Barnes May 15 '13 at 03:49
  • Thanks for your comment! Yes, but I'm not quite sure on how to use them with GeoCouch to solve my problem efficiently. – Dexter May 15 '13 at 11:30
  • 2
    Check [this](https://github.com/couchbase/geocouch/#list-function-support) out, it looks like you can create a view index that outputs all the documents you need. In your list function, you iterate as normal, but you only output the data you need. In a list function, you have access to querystring parameters, so you can use that data to determine your filtering method. – Dominic Barnes May 15 '13 at 13:53
  • Thanks for the tip, this could be an helpful workaround in case I don't find another solution! ([see here](http://stackoverflow.com/a/3638678/261698)) – Dexter May 15 '13 at 15:59
  • 1
    did you end up finding a solution you could share? – Erik Kaplun Mar 26 '16 at 16:13
  • @ErikAllik, no. Unfortunately not. – Dexter Mar 28 '16 at 08:22

0 Answers0