File tree Expand file tree Collapse file tree 4 files changed +48
-7
lines changed Expand file tree Collapse file tree 4 files changed +48
-7
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,13 @@ class Builder extends BaseEloquentBuilder
4141 'matrix ' ,
4242 'query ' ,
4343 'rawSearch ' ,
44+ 'getIndexSettings ' ,
45+ 'getIndexMappings ' ,
46+ 'deleteIndexIfExists ' ,
47+ 'deleteIndex ' ,
48+ 'truncate ' ,
49+ 'indexExists ' ,
50+ 'createIndex ' ,
4451 ];
4552
4653
Original file line number Diff line number Diff line change @@ -770,6 +770,32 @@ public function deleteIndexIfExists()
770770
771771 }
772772
773+ public function getIndexMappings ()
774+ {
775+ return Schema::getMappings ($ this ->index );
776+ }
777+
778+ public function getIndexSettings ()
779+ {
780+ return Schema::getSettings ($ this ->index );
781+ }
782+
783+ public function indexExists ()
784+ {
785+ return Schema::hasIndex ($ this ->index );
786+ }
787+
788+ public function createIndex ()
789+ {
790+ if (!$ this ->indexExists ()) {
791+ $ this ->connection ->indexCreate ($ this ->index );
792+
793+ return true ;
794+ }
795+
796+ return false ;
797+ }
798+
773799 public function rawSearch (array $ bodyParams )
774800 {
775801 $ find = $ this ->connection ->searchRaw ($ bodyParams );
Original file line number Diff line number Diff line change @@ -20,18 +20,26 @@ public function __construct(Connection $connection)
2020 // View Index Meta
2121 //----------------------------------------------------------------------
2222
23- public function getIndices ($ all = false )
23+ public function getIndices ($ includeSystem = false )
2424 {
25- return $ this ->connection ->getIndices ($ all );
25+ return $ this ->connection ->getIndices ($ includeSystem );
2626 }
2727
28- public function getMappings ($ index )
28+ public function getMappings ($ index, $ forceIndexName = false )
2929 {
30+ if (!$ forceIndexName ) {
31+ $ index = $ this ->connection ->setIndex ($ index );
32+ }
33+
3034 return $ this ->connection ->indexMappings ($ index );
3135 }
3236
33- public function getSettings ($ index )
37+ public function getSettings ($ index, $ forceIndexName = false )
3438 {
39+ if (!$ forceIndexName ) {
40+ $ index = $ this ->connection ->setIndex ($ index );
41+ }
42+
3543 return $ this ->connection ->indexSettings ($ index );
3644 }
3745
Original file line number Diff line number Diff line change 55use Illuminate \Support \Facades \Facade ;
66
77/**
8- * @method static Builder getIndices(bool $all = null )
9- * @method static Builder getMappings(string $index)
10- * @method static Builder getSettings(string $index)
8+ * @method static Builder getIndices(bool $includeSystem = false )
9+ * @method static Builder getMappings(string $index, $forceIndexName = false )
10+ * @method static Builder getSettings(string $index, $forceIndexName = false )
1111 * @method static Builder create(string $index, \Closure $callback)
1212 * @method static Builder createIfNotExists(string $index, \Closure $callback)
1313 * @method static Builder reIndex(string $from, string $to)
You can’t perform that action at this time.
0 commit comments