Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-45833

Sorting with collation that has `numericOrdering`, `alternate`, and `shifted` seems to ignore `numericOrdering`

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.2.3
    • Component/s: None
    • Labels:
    • Environment:
      Ubuntu 18.04 with XFCE
    • Fully Compatible
    • ALL
    • Hide

      Run the given script. I ran it using MongoDB server and shell 4.2.3-rc1

      Show
      Run the given script. I ran it using MongoDB server and shell 4.2.3-rc1

      The below script prints that "950 000" before "970". I'd expect that the given collation makes MongoDB ignore whitespace and treat "950 000" as "950000"

      db.dropDatabase();
      
      db.createCollection('test', {
        collation: {
          locale: "en_US",
          numericOrdering: true,
          alternate: "shifted",
          maxVariable: "punct"
        }
      });
      
      db.test.insertMany([
        { price: '970' },
        { price: '950 000' }
      ]);
      
      var res = db.test.find({}).collation({
        locale: "en_US",
        numericOrdering: true,
        alternate: "shifted",
        maxVariable: "space"
      }).sort({ price: 1 }).toArray();
      
      print(res[0].price); // 950 000
      print(res[1].price); // 970
      

            Assignee:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Reporter:
            val@karpov.io Valeri Karpov
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: