Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-914

"Can't canonicalize query" Error occures when retrieving documents.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.5
    • Affects Version/s: 2.0.4
    • Component/s: Sharded Cluster
    • None
    • Environment:
      CentOS 6.4
      Ruby 2.1.2

      Specifies following options in "Mongo::Client".

      • Connects to a mongos server. and
      • Not specifies ":connect => :sharded". and
      • Specifies "primary_preferred" to a read preference.
        Rerieves documents by using "find" method.

      But "find" method runs well if following options are specified in "Mongo::Client".

      • Specifies ":connect => :sharded". or
      • Specifies "primary" to a read preference.

      Ruby Code
      =========
      require 'mongo'
      db = Mongo::Client.new(
      ['test-server:20001'],
      {
      :database => "test",
      :user => "test_user",
      :password => "test_pass",

      1. :connect => :sharded, # find method runs well when ":connect => :sharded" is specified.
        :read => { :mode => :primary_preferred } # find method runs well when ":primary" is specified.
        }
        )
        cur = db["test"].find()
        col = nil; cur.each { |c| col = c; break }

        puts( col )

      Result
      ======

      {"$err"=>"Can't canonicalize query: BadValue unknown top level operator: $readPreference", "code"=>17287}

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            incredible_hana Onari Tanaka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: