| @@ 1214-1227 (lines=14) @@ | ||
| 1211 | * @param string $field |
|
| 1212 | * @return \Sokil\Mongo\Collection |
|
| 1213 | */ |
|
| 1214 | public function ensure2dSphereIndex($field) |
|
| 1215 | { |
|
| 1216 | if (is_array($field)) { |
|
| 1217 | $keys = array_fill_keys($field, '2dsphere'); |
|
| 1218 | } else { |
|
| 1219 | $keys = array( |
|
| 1220 | $field => '2dsphere', |
|
| 1221 | ); |
|
| 1222 | } |
|
| 1223 | ||
| 1224 | $this->_mongoCollection->ensureIndex($keys); |
|
| 1225 | ||
| 1226 | return $this; |
|
| 1227 | } |
|
| 1228 | ||
| 1229 | /** |
|
| 1230 | * Create geo index 2dsphere |
|
| @@ 1237-1250 (lines=14) @@ | ||
| 1234 | * @param string $field |
|
| 1235 | * @return \Sokil\Mongo\Collection |
|
| 1236 | */ |
|
| 1237 | public function ensure2dIndex($field) |
|
| 1238 | { |
|
| 1239 | if (is_array($field)) { |
|
| 1240 | $keys = array_fill_keys($field, '2d'); |
|
| 1241 | } else { |
|
| 1242 | $keys = array( |
|
| 1243 | $field => '2d', |
|
| 1244 | ); |
|
| 1245 | } |
|
| 1246 | ||
| 1247 | $this->_mongoCollection->ensureIndex($keys); |
|
| 1248 | ||
| 1249 | return $this; |
|
| 1250 | } |
|
| 1251 | ||
| 1252 | /** |
|
| 1253 | * Create fulltext index |
|