| @@ 1232-1245 (lines=14) @@ | ||
| 1229 | * @param string $field |
|
| 1230 | * @return \Sokil\Mongo\Collection |
|
| 1231 | */ |
|
| 1232 | public function ensure2dSphereIndex($field) |
|
| 1233 | { |
|
| 1234 | if (is_array($field)) { |
|
| 1235 | $keys = array_fill_keys($field, '2dsphere'); |
|
| 1236 | } else { |
|
| 1237 | $keys = array( |
|
| 1238 | $field => '2dsphere', |
|
| 1239 | ); |
|
| 1240 | } |
|
| 1241 | ||
| 1242 | $this->_mongoCollection->ensureIndex($keys); |
|
| 1243 | ||
| 1244 | return $this; |
|
| 1245 | } |
|
| 1246 | ||
| 1247 | /** |
|
| 1248 | * Create geo index 2dsphere |
|
| @@ 1255-1268 (lines=14) @@ | ||
| 1252 | * @param string $field |
|
| 1253 | * @return \Sokil\Mongo\Collection |
|
| 1254 | */ |
|
| 1255 | public function ensure2dIndex($field) |
|
| 1256 | { |
|
| 1257 | if (is_array($field)) { |
|
| 1258 | $keys = array_fill_keys($field, '2d'); |
|
| 1259 | } else { |
|
| 1260 | $keys = array( |
|
| 1261 | $field => '2d', |
|
| 1262 | ); |
|
| 1263 | } |
|
| 1264 | ||
| 1265 | $this->_mongoCollection->ensureIndex($keys); |
|
| 1266 | ||
| 1267 | return $this; |
|
| 1268 | } |
|
| 1269 | ||
| 1270 | /** |
|
| 1271 | * Create fulltext index |
|