File tree 4 files changed +59
-1
lines changed
4 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,15 @@ public function select($columns = array('*'))
129
129
return $ this ->query ()->select (is_array ($ columns ) ? $ columns : func_get_args ());
130
130
}
131
131
132
+ /**
133
+ * Create the index.
134
+ *
135
+ * @param array $fields
136
+ *
137
+ * @return bool
138
+ */
139
+ abstract public function createIndex (array $ fields = array ());
140
+
132
141
/**
133
142
* Get a new query instance from the driver.
134
143
*
Original file line number Diff line number Diff line change @@ -43,7 +43,19 @@ protected function getClient()
43
43
}
44
44
45
45
/**
46
- * Get the ZendSearch lucene index instance associated with this instance.
46
+ * Create the index.
47
+ *
48
+ * @param array $fields
49
+ *
50
+ * @return bool
51
+ */
52
+ public function createIndex (array $ fields = array ())
53
+ {
54
+ return false ;
55
+ }
56
+
57
+ /**
58
+ * Get the Algolia index instance associated with this instance.
47
59
*
48
60
* @return \AlgoliaSearch\Index
49
61
*/
Original file line number Diff line number Diff line change @@ -41,6 +41,31 @@ protected function getClient()
41
41
return static ::$ client ;
42
42
}
43
43
44
+ /**
45
+ * Create the index.
46
+ *
47
+ * @param array $fields
48
+ *
49
+ * @return bool
50
+ */
51
+ public function createIndex (array $ fields = array ())
52
+ {
53
+ $ properties = array ('_geoloc ' => array ('type ' => 'geo_point ' ));
54
+
55
+ foreach ($ fields as $ field ) {
56
+ $ properties [$ field ] = array ('type ' => 'string ' );
57
+ }
58
+
59
+ $ body ['mappings ' ][static ::$ default_type ]['properties ' ] = $ properties ;
60
+
61
+ $ this ->getClient ()->indices ()->create (array (
62
+ 'index ' => $ this ->name ,
63
+ 'body ' => $ body ,
64
+ ));
65
+
66
+ return true ;
67
+ }
68
+
44
69
/**
45
70
* Get a new query instance from the driver.
46
71
*
Original file line number Diff line number Diff line change @@ -32,6 +32,18 @@ public function __construct($name, $driver)
32
32
* @var array
33
33
*/
34
34
protected $ stored_query_totals = array ();
35
+
36
+ /**
37
+ * Create the index.
38
+ *
39
+ * @param array $fields
40
+ *
41
+ * @return bool
42
+ */
43
+ public function createIndex (array $ fields = array ())
44
+ {
45
+ return false ;
46
+ }
35
47
36
48
/**
37
49
* Get the ZendSearch lucene index instance associated with this instance.
You can’t perform that action at this time.
0 commit comments