D
D
demon24ru2020-08-09 08:14:05
JavaScript
demon24ru, 2020-08-09 08:14:05

PouchDB (CouchDB) how to properly organize a GIS search by entity name?

Question of the following plan:
We have 3000+ points on the map entered into the database, each as a separate document with _id in the form of Geohash example:

{
  "_id": "y1h8vmsum",
  "_rev": "1-sdfsdfsdfsdfsdfsdfsdfsdf"
}

And we have a second database in which 10,000 + types of goods are entered, each product is a separate document example:
{
  "_id": "0B3358C1-BA4B-4186-8795-9024203EB7DD",
  "name": "Супер пупер товар"
}

The relationship between outlets and products, if guided by the relational database model, as many-to-many. That is, at each point there can be several or all types of goods, respectively, one type of goods can be at several points.
The next question is how to organize a search for types of goods by name in a certain radius on the map from a certain location?
Upd:
Databases in pouchDB they are replicated to the mobile device, there, on the mobile device, they are only read and the above GEO-Query must be done.
There is a suspicion that this issue can be solved like this:
In the document of each type of product, we push an array of points where it can be located, an example:
{
  "_id": "0B3358C1-BA4B-4186-8795-9024203EB7DD",
  "name": "Супер пупер товар",
  "points": [
    "y1h8vmsum",
    "y1h8vmvmv"
  ]
}

We search by the field "name" $and "points"
pouchBase.find({
  selector: {
    name: "Супер пупер товар",
    "$elemMatch": {
      "points": "... Каким то макаром поинты в радиусе"
     }
  }
});

But if you shove an array of points within a radius of the device, there can be all 3000+ of them, the request will first die on data transfer to pouchDB, then the database itself will die during processing.
Is it possible to solve this issue one way or another, given that geo-query queries must be performed offline on a mobile device?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kocherman, 2020-08-09
@kocherman

The formula for the distance between two coordinates is here .
/* Free tip */ Replace PouchDB (CouchDB) with Mongo or PostGIS.
PouchDB (CouchDB) is not optimized for geoqueries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question