Comments (1)
After reading the source code and mongo's docs (and with the help of ChatGPT) I've fould the following:
The reason why when I do the engine.find
it fails is because the find method uses internally an aggregation pipeline where the find queries are set inside a $match stage. And because "You cannot use $near or $nearSphere in
$match queries as part of the aggregation pipeline" (from the MongoDB docs) then that's why the query fails (It would be nice if the OperationFailure error said this insead of the more generic "...are not allowed in this context").
The docs suggest to:
"
Use $geoNear stage instead of the $match stage.
Use $geoWithin query operator with $center or $centerSphere in the $match stage.
"
Is there a way to add the geoNear stage to the _prepare_find_pipeline
method? I don't know what the best way to do it, if the queries should go in the queries parameter or in a separate one (or if there should be a different find method that allows this kind of queries).
from odmantic.
Related Issues (20)
- Can't change a field in a copied embedded model that's part of a collection #228
- When the time is inserted into the database HOT 2
- Abstract models HOT 1
- is_type_mutable returns true for Literal types
- `database` argument for `Engine`s defaulted to `"test"` is unexpected
- Union of embedded models regression
- Exclude a field from serialization and saving into database
- Embedded Model Exclude None Not Functioning HOT 1
- Support native validator
- Using the union operator in model breaks HOT 1
- FastAPI schema can not show the fields in parent odmantic.Model class
- Add support for Pydantic V2 HOT 13
- Odmantic model names in openapi.json from FastAPI have __pydantic_model__ suffix
- ζδΉζεΊ HOT 1
- Pydantic URLs have stopped working
- Support other document store
- Using deprecated `pydantic.datetime_parse:parse_datetime` in Pydantic HOT 1
- Can't start dev container: multi-python is deprecated
- Optional EmbeddedModel not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odmantic.