Use find() on view

89 views
Skip to first unread message

peter.s...@googlemail.com

unread,
Dec 18, 2017, 11:57:56 AM12/18/17
to ReactiveMongo - http://reactivemongo.org

Hi reactive mongo group!

Using collection.find() on a mongo db view yields the following exception:

13:34:32.388 ERROR[technology-actor-system-akka.actor.default-dispatcher-7] Cursor - fails to send request
reactivemongo
.core.errors.DetailedDatabaseException: DatabaseException['Namespace someDb.someView is a view. Legacy find operations are not supported on views. Only clients which support the find command can be used to query views.' (code = 166)]

After enable query logging on the mongo db itself, it prints me:

2017-12-18T16:02:55.234+0000 I QUERY    [conn795] assertion CommandNotSupportedOnView: Namespace someDb.someView is a view. Legacy find operations are not supported on views. Only clients which support the find command can be used to query views. ns:someDb.someView query:{ $query: {}, $readPreference: { mode: "primary" } }

Using a different client (pyMongo) the following query is logged:

2017-12-18T15:49:15.701+0000 I COMMAND  [conn793] command someDb.someView command: find { find: "someView", filter: {}, $readPreference: { mode: "secondaryPreferred" }, $db: "someDb" } planSummary: COLLSCAN keysExamined:0 docsExamined:292 cursorExhausted:1 numYields:2 nreturned:2 reslen:361886 locks:{ Global: { acquireCount: { r: 18136 } }, Database: { acquireCount: { r: 9068 } }, Collection: { acquireCount: { r: 9067 } } } protocol:op_query 441ms

I am not a mongodb expert, but it seems like there is a legacy command set for mongodb, which is still used in the reactive mongo driver.

Does someone have more insights about this? And there ways to avoid the problem?

Cédric Chantepie

unread,
Dec 20, 2017, 1:11:59 PM12/20/17
to ReactiveMongo - http://reactivemongo.org
View support is pending (as for some reason plain find doesn't work for). Can use direct aggregation as workaround.

peter.s...@googlemail.com

unread,
Dec 28, 2017, 5:07:14 AM12/28/17
to ReactiveMongo - http://reactivemongo.org
Thanks for the heads up. 

I solved it like proposed.
Reply all
Reply to author
Forward
0 new messages