Details

    • # Replies:
      40
    • Last comment by Customer:
      true

      Description

      Dear developers.

      Recently, I've encountered a situation, in which a document contained and integer value with a bitwise flag logic.
      Unfortunately, MongoDB's $and and $or do not support bitwise logic.
      Is it possible to implement that? Should it be filed as a feature request?

      Thank you.

        Issue Links

          Activity

          Hide
          Ali Gangji
          added a comment -

          That doesn't seem any easier to work with. You're right that the query itself is shorter because you can add the values you are looking for rather than enumerate them. However, if you have 30 bitwise flags you certainly won't be working with numbers like 126. 2^30 is 1073741824. Using bigint, once you've hit 62 flags, that is the highest number of bitwise flags you can have and store them all together and you're reaching the limit and using up a 64-bit int.

          Secondly, an embedded array can be indexed by MongoDB. So by using arrays you won't be limited in the number of possible values or the size of int/bigint AND your query can use an index and be very fast. It's also easier to manage because you don't have to convert your flags to their bit position. The only disadvantage is a longer query, which i'd say is trivial.

          Show
          Ali Gangji
          added a comment - That doesn't seem any easier to work with. You're right that the query itself is shorter because you can add the values you are looking for rather than enumerate them. However, if you have 30 bitwise flags you certainly won't be working with numbers like 126. 2^30 is 1073741824. Using bigint, once you've hit 62 flags, that is the highest number of bitwise flags you can have and store them all together and you're reaching the limit and using up a 64-bit int. Secondly, an embedded array can be indexed by MongoDB. So by using arrays you won't be limited in the number of possible values or the size of int/bigint AND your query can use an index and be very fast. It's also easier to manage because you don't have to convert your flags to their bit position. The only disadvantage is a longer query, which i'd say is trivial.
          Hide
          guipulsar
          added a comment - - edited

          im simply not agree at all.. first our flow has been reflect from years, all apps input are capped to 50 , all this discussion has been benchmarked for a while you know.. Think an application who search for 15 keywords with 30 variation for each ..You continue to agree for putting 450 keywords string in ur post ? lol
          if its trivial for you, i guess we are not talking of the same things...You should call google to inform them that string array are more powerfull bitwise...

          Show
          guipulsar
          added a comment - - edited im simply not agree at all.. first our flow has been reflect from years, all apps input are capped to 50 , all this discussion has been benchmarked for a while you know.. Think an application who search for 15 keywords with 30 variation for each ..You continue to agree for putting 450 keywords string in ur post ? lol if its trivial for you, i guess we are not talking of the same things...You should call google to inform them that string array are more powerfull bitwise...
          Hide
          Ali Gangji
          added a comment -

          I didn't say anything about 450 keywords. I don't know the details of your application. Maybe bitwise flags are more useful for your purposes. It's possible a different architecture would be required to eliminate your usage of bitwise flags.

          Awyways, I am not a MongoDB developer and have no control over their development path. I'm watching this issue myself because I'm interested in this feature becoming available. I'm only trying to help point you to the alternatives that exist today. I wish you good luck!

          Show
          Ali Gangji
          added a comment - I didn't say anything about 450 keywords. I don't know the details of your application. Maybe bitwise flags are more useful for your purposes. It's possible a different architecture would be required to eliminate your usage of bitwise flags. Awyways, I am not a MongoDB developer and have no control over their development path. I'm watching this issue myself because I'm interested in this feature becoming available. I'm only trying to help point you to the alternatives that exist today. I wish you good luck!
          Hide
          guipulsar
          added a comment -

          thhanks for ur alternative propositions but concerning bitwise there are no really alternative , thats why its so much important thing and future, i will continue to pushup this feature request , honestly i think mongo devloppers made a serious mistake when flagging this at " trivial " and "planing but not scheduled " ;
          In fact , because this statut , we're thinking to move for another nosql solution... we are pretty grow company with many projects , we find mongo interesting , but the lack of bitwise is a serious thing unfortunatly. I guess im not alone at all in this case . Hope developers will manifest some talk about , before many projects leave away ..

          Show
          guipulsar
          added a comment - thhanks for ur alternative propositions but concerning bitwise there are no really alternative , thats why its so much important thing and future, i will continue to pushup this feature request , honestly i think mongo devloppers made a serious mistake when flagging this at " trivial " and "planing but not scheduled " ; In fact , because this statut , we're thinking to move for another nosql solution... we are pretty grow company with many projects , we find mongo interesting , but the lack of bitwise is a serious thing unfortunatly. I guess im not alone at all in this case . Hope developers will manifest some talk about , before many projects leave away ..
          Hide
          Vincent Robert
          added a comment -

          We fully agree with the comments of Guipulsar and our position is similar. We have requested this feature a very long time ago and we still have no planning/schedule for the implementation. This is not serious.

          Show
          Vincent Robert
          added a comment - We fully agree with the comments of Guipulsar and our position is similar. We have requested this feature a very long time ago and we still have no planning/schedule for the implementation. This is not serious.

            People

              Dates

              • Created:
                Updated:
                Days since reply:
                9 weeks, 1 day ago
                Date of 1st Reply: