I know that MongoDB does not support searching by text index
and geospatial index
at the same time, as written here. But I saw suggestions to use $geoWithin
instead of $near
. I am using $geoWithin
with $box geometry
and it doesn't yield any results. However, when I use $geoWithin
and $center
geometry, it does work. What may be wrong? Is it not supported? Is it a bug? Of course that if I apply those query conditions separately (text and geo spatial), it all works.
MongoDB text search and geoWithin search
339 views Asked by Josef Sábl At
1
Although it is mentioned several times in documentation that
$geoWithin
does not require geospatial index. I could not make it work with$box
operator.This is not working:
Pretty easy workaround is to use
$gte
and$lte
operators instead.Working solution:
I, however, am not sure about performance of such query.