Issue with the "$gt and $lt" options in Aggregation Pipeline

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.11
    • Component/s: Aggregation Framework
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      My collection containes documents as follow:
      *****************************************************************
      /* 1 */

      { "_id" : ObjectId("591dae6ae320467808f1e198"), "scenario" : "delc", "datavalue" : [ " _value: ", "A _value: 8", "B _value: 5", "C _value: 2", "D _value:4" ] }

      /* 2 */

      { "_id" : ObjectId("591dae83e320467808f1e199"), "scenario" : "delc", "datavalue" : [ " _value: ", "A _value: 4", "B _value: 5", "C _value: 92", "D _value:94" ] }

      /* 3 */

      { "_id" : ObjectId("591dae9ae320467808f1e19a"), "scenario" : "delc", "datavalue" : [ " _value: ", "A _value: 2", "C _value: 2", "D _value:4" ] }

      **********************************************************************

      When I want to search for "datavalue grater than A _value: 6" it does not work (returns all the documents) with simple $match $project as follow :
      *************************************************
      db.getCollection('test').aggregate([
      {$match : {datavalue :

      { $gt : 'A _value: 6'}

      }},
      { $project: { scenario: 1,
      datavalue: { $filter: { input: "$datavalue", as: "datavalue",
      cond: {
      $or: [ { $eq: [

      { $substr: [ "$$datavalue", 0, 1 ] }

      , "A" ] } ] } } }
      } }])
      *************************************************
      If I add another $match (the same as the first one) to the pipeline the results are OK, but if I add a condition "searching for documents with datavalue grater than A _value: 6 and datavalue starts with B" it returns all the documents (I attached an image)

            Assignee:
            Unassigned
            Reporter:
            Marwa FRIAA [X]
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: