previously, (when using reindexing API) location fields looked like this:
"location": { "lat": 45.4215, "lon": -75.6972 },
Now, they look like this after using PGSync:
"location": { "latitude": 40.7128, "longitude": -74.006 },
When I search by location, I currently get this error:
.
In short, if location can't be changed to "lat" and "lon" instead of "latitude" and "longitude" using the PGSync schema (or some other method), we won't be able to search within 5 km of or sort by location.
Meanwhile, PGSync has the issue where it does not recognize the LOCATION_TYPE defined in PGSync
I have not been able to figure out how to resolve this.
Uncomment the location based filtering and sorting code in the /api/search endpoint in routes.py
In terminal in the martletplace directory, run docker-compose down , then docker-compose up --build elasticsearch database pgsync search (this builds a reduced portion of the application)
Once the application has finished building successfully, uncomment this test in test_server.py:
In a fresh terminal, run docker exec -it martletplace_search bash
In the resulting bash terminal, run pytest src/test_server.py (this runs the tests)
Expected behaviour
All tests pass without issue
Actual (problematic) behavior
A number of tests fail for this reason:
Suggested fix
Figure out a way to modify the pgsync schema.json to apply the following transformation:
In postgres
"location": { "latitude": 45.4215, "longitude": -75.6972 },
In elasticsearch
"location": { "lat": 40.7128, "lon": -74.006 },
Describe the bug
I'm running into the problem where elasticsearch requires location fields to be mapped as geo_point with the fields "lat" and "lon" in order to search by location (https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html).
previously, (when using reindexing API) location fields looked like this:
"location": { "lat": 45.4215, "lon": -75.6972 },
Now, they look like this after using PGSync:
"location": { "latitude": 40.7128, "longitude": -74.006 },
When I search by location, I currently get this error:
.
In short, if location can't be changed to "lat" and "lon" instead of "latitude" and "longitude" using the PGSync schema (or some other method), we won't be able to search within 5 km of or sort by location.
Meanwhile, PGSync has the issue where it does not recognize the LOCATION_TYPE defined in PGSync![image](https://github.com/UVicMartletplace/martletplace/assets/90437591/71b240b6-6646-45b1-897e-5f20cb893205)
I have not been able to figure out how to resolve this.
Originally posted by @GDeane in https://github.com/UVicMartletplace/martletplace/issues/214#issuecomment-2190722842
To Reproduce
Steps to reproduce the behaviour:
Uncomment the location based filtering and sorting code in the /api/search endpoint in routes.py![Image](https://github.com/UVicMartletplace/martletplace/assets/90437591/0f9ec6cb-5793-4508-b1bd-cd34d9b77ef8)
In terminal in the martletplace directory, run
docker-compose down
, thendocker-compose up --build elasticsearch database pgsync search
(this builds a reduced portion of the application)Once the application has finished building successfully, uncomment this test in test_server.py:![Image](https://github.com/UVicMartletplace/martletplace/assets/90437591/e45f088b-88e0-4dc3-9f96-481a3633e7d8)
In a fresh terminal, run
docker exec -it martletplace_search bash
In the resulting bash terminal, run
pytest src/test_server.py
(this runs the tests)Expected behaviour
All tests pass without issue
Actual (problematic) behavior
A number of tests fail for this reason:![Image](https://github.com/UVicMartletplace/martletplace/assets/90437591/068779b6-6cc7-4780-8cd1-0bbcfa5dc52e)
Suggested fix
Figure out a way to modify the pgsync schema.json to apply the following transformation:
In postgres
"location": { "latitude": 45.4215, "longitude": -75.6972 },
In elasticsearch
"location": { "lat": 40.7128, "lon": -74.006 },
Everything location related should work then.