| @@ 1118-1131 (lines=14) @@ | ||
| 1115 | * @param string $field |
|
| 1116 | * @return \Sokil\Mongo\Collection |
|
| 1117 | */ |
|
| 1118 | public function ensure2dSphereIndex($field) |
|
| 1119 | { |
|
| 1120 | if (is_array($field)) { |
|
| 1121 | $keys = array_fill_keys($field, '2dsphere'); |
|
| 1122 | } else { |
|
| 1123 | $keys = array( |
|
| 1124 | $field => '2dsphere', |
|
| 1125 | ); |
|
| 1126 | } |
|
| 1127 | ||
| 1128 | $this->_mongoCollection->ensureIndex($keys); |
|
| 1129 | ||
| 1130 | return $this; |
|
| 1131 | } |
|
| 1132 | ||
| 1133 | /** |
|
| 1134 | * Create geo index 2dsphere |
|
| @@ 1141-1154 (lines=14) @@ | ||
| 1138 | * @param string $field |
|
| 1139 | * @return \Sokil\Mongo\Collection |
|
| 1140 | */ |
|
| 1141 | public function ensure2dIndex($field) |
|
| 1142 | { |
|
| 1143 | if (is_array($field)) { |
|
| 1144 | $keys = array_fill_keys($field, '2d'); |
|
| 1145 | } else { |
|
| 1146 | $keys = array( |
|
| 1147 | $field => '2d', |
|
| 1148 | ); |
|
| 1149 | } |
|
| 1150 | ||
| 1151 | $this->_mongoCollection->ensureIndex($keys); |
|
| 1152 | ||
| 1153 | return $this; |
|
| 1154 | } |
|
| 1155 | ||
| 1156 | /** |
|
| 1157 | * Create fulltext index |
|