title: How to ignore null parameters in mongodb criteria query
body: <pre><code> List&lt;Property&gt; properties;
   Criteria criteria = new Criteria();
  
  criteria.andOperator(
              Criteria.where("published").is(true),
              Criteria.where("location.district").regex(model.getLocation(),"i").orOperator(Criteria.where("location.city").exists(true).regex(model.getLocation(),"i")),
              Criteria.where("basicInfo.propertyType").is(model.getPropertyType()),
              Criteria.where("priceInfo.price").gte(prices[0]).lte(prices[1]),
              Criteria.where("bedspace").gte(model.getAdult()).orOperator(Criteria.where("bedspace").gte(model.getChild())),
              Criteria.where("unavailableDates").ne(model.getCheckinDate()).andOperator(Criteria.where("unavalibleDates").ne(model.getCheckoutDate())),
              Criteria.where("location.coords").within(box));
  
      Query query = new Query(criteria);
      properties = mongoTemplate.find(query, Property.class);
  </code></pre>
  
  <p>My code basically works like that. My aim is to create search mechanism where user will enter a location info to start searching and then by adding extra filters customize his/her search. I put them in andOperator because i want this search to be specified to location parameter.</p>
  
  <p>E.g : You search for Germany then you add filter for pricing for example between 0-100 then search should act
  :
  return houses from germany that is priced between 0-100</p>
  
  <p>But there is a problem.
  When an user enters location query model only consist of location parameter which means other parameters in query model is null and when it enters andOperator it gives null pointer exception. I want it to ignore null parameters and move on with the other ones. How can i achieve that?</p>
  
  <p>I tried adding ne(null) field but it didnt help</p>
  
  <pre><code> Criteria.where("location.coords").ne(null).within(box));
  </code></pre>
  
  <p>thanks in advance,</p>