Full Text Search combined with Geo Spatial query?

908 views
Skip to first unread message

Brian Cameron

unread,
Jun 17, 2014, 5:20:01 PM6/17/14
to mongod...@googlegroups.com
Hi folks,

I have recently converted an application from PostGIS/Rails to the MEAN stack. I've been very happy with almost everything however I have hit one issue which I cannot find any obvious answer/work around for.

My application is a search tool that has both Geospatial and Text descriptions and I would like to be able to combine both together in the same query.

This is apparently not possible (example error message below):

find(   {     "add.loc": {$near: {$geometry: {type: "Point", coordinates: [116.425, -31.09]}, $maxDistance: 500000}},      $text: {$search: "hello"}   },    {     _id:0,     fname:1,     lname:1,     add:1,   } ).count()
2014-05-07T01:19:37.956+0200 count failed: {
"errmsg" : "exception: text and geoNear not allowed in same query",
"code" : 2,
"ok" : 0
} at src/mongo/shell/query.js:191

My questions is this: Is there any kind of work around for this (that would be better then merging the results by hand from two queries... This would work but I'd rather find a more elegant solution).

What about the map reduce framework? Reporting framework? (I'm not yet familiar with these)

Any tips would be greatly appreciated! There must be a nice way to make this work in Mongo! :-)

Thanks very much!
Brian.

Asya Kamsky

unread,
Jun 18, 2014, 6:50:31 PM6/18/14
to mongodb-user
It's possible to query of both types but not to use both special indexes - so you can have a text search using text index and then do an in-memory geospatial filter on the selected results (without the benefit of the geo index).

I believe you need to use the $geoWithin rather than $near for that to work since $near requires a geospatial index.


$geoWithin does not require an index

Asya





--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/8e61096b-6a35-481b-810e-b51719d1761b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rishi Sharma

unread,
Jul 19, 2014, 6:21:19 PM7/19/14
to mongod...@googlegroups.com
Is there a JIRA ticket or plans to allow for the intersection of the text and geospatial indexes? This is a common use case in content search engines.

Asya Kamsky

unread,
Jul 20, 2014, 1:11:16 AM7/20/14
to mongodb-user
I couldn't find one, so if you don't mind opening one so it can be triaged, I think that would be good.

If I missed it then your will be marked a duplicate of it...

Asya



Reply all
Reply to author
Forward
0 new messages