Mongo: find all documents that match more than three items from an array [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • Mongodb count all array elements in all objects matching by criteria

    2 answers



  • How to Count Matched array elements

    1 answer




I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.



var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]

return Shoe.find({ shoeTags: { $in: userTags}});


// this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array










share|improve this question















marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 3:29


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















    up vote
    0
    down vote

    favorite













    This question already has an answer here:




    • Mongodb count all array elements in all objects matching by criteria

      2 answers



    • How to Count Matched array elements

      1 answer




    I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.



    var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]

    return Shoe.find({ shoeTags: { $in: userTags}});


    // this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array










    share|improve this question















    marked as duplicate by Neil Lunn mongodb
    Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 12 at 3:29


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:




      • Mongodb count all array elements in all objects matching by criteria

        2 answers



      • How to Count Matched array elements

        1 answer




      I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.



      var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]

      return Shoe.find({ shoeTags: { $in: userTags}});


      // this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array










      share|improve this question
















      This question already has an answer here:




      • Mongodb count all array elements in all objects matching by criteria

        2 answers



      • How to Count Matched array elements

        1 answer




      I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.



      var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]

      return Shoe.find({ shoeTags: { $in: userTags}});


      // this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array





      This question already has an answer here:




      • Mongodb count all array elements in all objects matching by criteria

        2 answers



      • How to Count Matched array elements

        1 answer








      mongodb






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 3:32









      Neil Lunn

      96.4k22169180




      96.4k22169180










      asked Nov 12 at 3:27









      zschrief

      1




      1




      marked as duplicate by Neil Lunn mongodb
      Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 12 at 3:29


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Neil Lunn mongodb
      Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 12 at 3:29


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.































          active

          oldest

          votes






















          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to pass form data using jquery Ajax to insert data in database?

          National Museum of Racing and Hall of Fame

          Guess what letter conforming each word