Query with text index clogs mongod

38 views
Skip to first unread message

iv...@entryless.com

unread,
Aug 23, 2016, 7:56:59 PM8/23/16
to mongodb-user
Hello,

I have a database with about 1.5 million documents in it. I used several string fields (about 8 string fields in subdocuments in a record) to build a text index. I do a query like this:

db.collection.find({"company_id":company_id, "$text":{"$search":keyword}})

Sometimes the query finishes throwing wrong results (it does not find documents that comply with the search criteria). But most of
the time the query does not finishes at all and after a while, any incoming connection to the mongod is rejected. I tried to connect to it
with mongo shell and I get a error connection 111: Connection refused. I have to restart mongod to make it responsive again.

Is there something with my text index? Or is this a bug?

Any help would be appreciated.

Thanks!
Ivan

Valtteri Pirttilä

unread,
Aug 24, 2016, 7:15:31 AM8/24/16
to mongodb-user
Hi!

Could you provide the index also? My experience is that when Mongo freezes, it usually means I'm not hitting an index like I thought I would. The operation simply ends up taking forever because it has to do a collection scan.

You could also try to get the explanation of the query to see what's going on:

db.collection.find({"company_id":company_id, "$text":{"$search":keyword}}).explain()

Valtteri
Reply all
Reply to author
Forward
0 new messages