Php mongo find only use 4 criteria

-> See updates below, I reproduced the same issue in Mongo shell

My criteria is passed through the GET parameters and placed in $ data (as an assc array). He then moves on to the section below, where each search term becomes partially inaccurate. After that we delete (cancel) empty criteria.

A total of 15 fields are possible, which can be set at least 1 and no more than 15.

foreach ($data as $k => $v) { 
     // Make them partial match
     $data[$k] = new MongoRegex('/'.$v.'/i');
     // Remove empty criteria
     if (empty($v)) unset($data[$k]); 
}
// Run the search
$cursor = $this->collection->find($data);

Everything works sweetly if the accepted criteria are 4 or less:

Array ( 
   [phone] => MongoRegex Object ( [regex] => 433 [flags] => i ) 
   [property_name] => MongoRegex Object ( [regex] => west [flags] => i ) 
   [city] => MongoRegex Object ( [regex] => H [flags] => i ) 
   [zip_postcode] => MongoRegex Object ( [regex] => 9 [flags] => i ) 
)

This returns 5 results.

But any criteria added after the 4th are ineffective.

Array ( 
   [phone] => MongoRegex Object ( [regex] => 433 [flags] => i ) 
   [state_province] => MongoRegex Object ( [regex] => Virginia [flags] => i ) 
   [property_name] => MongoRegex Object ( [regex] => west [flags] => i ) 
   [city] => MongoRegex Object ( [regex] => H [flags] => i ) 
   [zip_postcode] => MongoRegex Object ( [regex] => 9 [flags] => i )
)

This should return 2, but still return 5, and it will return 5 no matter how many elements of the elements are added.

- Update -

, Shell , , .

db.property_list.find({phone:/433/, property_name:/west/, city:/h/, zip_postcode:/9/}).count()

5

, 5- , 2, - 5!!!

db.property_list.find({phone:/433/, property_name:/west/, city:/h/, zip_postcode:/9/, state_province:/Virginia/}).count()

5

, 4 !! , 'state_province' 'city', "", , 5- !

- -

, 5- , . , () 4 ? , 1

db.property_list.find({phone:/433/, property_name:/west/, city:/h/, zip_postcode:/9/, state_province:Virginia}).count()
+5

All Articles