@@ -903,93 +903,26 @@ func (c *Client) PerformRequest(method, path string, params url.Values, body int
903
903
return resp , nil
904
904
}
905
905
906
- // ElasticsearchVersion returns the version number of Elasticsearch
907
- // running on the given URL.
908
- func (c * Client ) ElasticsearchVersion (url string ) (string , error ) {
909
- res , _ , err := c .Ping (url ).Do ()
910
- if err != nil {
911
- return "" , err
912
- }
913
- return res .Version .Number , nil
914
- }
915
-
916
- // IndexNames returns the names of all indices in the cluster.
917
- func (c * Client ) IndexNames () ([]string , error ) {
918
- res , err := c .IndexGetSettings ().Index ("_all" ).Do ()
919
- if err != nil {
920
- return nil , err
921
- }
922
- var names []string
923
- for name , _ := range res {
924
- names = append (names , name )
925
- }
926
- return names , nil
927
- }
928
-
929
- // Ping checks if a given node in a cluster exists and (optionally)
930
- // returns some basic information about the Elasticsearch server,
931
- // e.g. the Elasticsearch version number.
932
- //
933
- // Notice that you need to specify a URL here explicitly.
934
- func (c * Client ) Ping (url string ) * PingService {
935
- return NewPingService (c ).URL (url )
936
- }
937
-
938
- // CreateIndex returns a service to create a new index.
939
- func (c * Client ) CreateIndex (name string ) * CreateIndexService {
940
- return NewCreateIndexService (c ).Index (name )
941
- }
942
-
943
- // DeleteIndex returns a service to delete an index.
944
- func (c * Client ) DeleteIndex (name string ) * DeleteIndexService {
945
- return NewDeleteIndexService (c ).Index (name )
946
- }
947
-
948
- // IndexExists allows to check if an index exists.
949
- func (c * Client ) IndexExists (name string ) * IndexExistsService {
950
- return NewIndexExistsService (c ).Index (name )
951
- }
952
-
953
- // TypeExists allows to check if one or more types exist in one or more indices.
954
- func (c * Client ) TypeExists () * IndicesExistsTypeService {
955
- return NewIndicesExistsTypeService (c )
956
- }
957
-
958
- // IndexStats provides statistics on different operations happining
959
- // in one or more indices.
960
- func (c * Client ) IndexStats (indices ... string ) * IndicesStatsService {
961
- return NewIndicesStatsService (c ).Index (indices ... )
962
- }
963
-
964
- // OpenIndex opens an index.
965
- func (c * Client ) OpenIndex (name string ) * OpenIndexService {
966
- return NewOpenIndexService (c ).Index (name )
967
- }
968
-
969
- // CloseIndex closes an index.
970
- func (c * Client ) CloseIndex (name string ) * CloseIndexService {
971
- return NewCloseIndexService (c ).Index (name )
972
- }
906
+ // -- Document APIs --
973
907
974
908
// Index a document.
975
909
func (c * Client ) Index () * IndexService {
976
910
return NewIndexService (c )
977
911
}
978
912
979
- // IndexGet retrieves information about one or more indices.
980
- // IndexGet is only available for Elasticsearch 1.4 or later.
981
- func (c * Client ) IndexGet (indices ... string ) * IndicesGetService {
982
- return NewIndicesGetService (c ).Index (indices ... )
913
+ // Get a document.
914
+ func (c * Client ) Get () * GetService {
915
+ return NewGetService (c )
983
916
}
984
917
985
- // IndexGetSettings retrieves settings about one or more indices .
986
- func (c * Client ) IndexGetSettings ( indices ... string ) * IndicesGetSettingsService {
987
- return NewIndicesGetSettingsService ( c ). Index ( indices ... )
918
+ // MultiGet retrieves multiple documents in one roundtrip .
919
+ func (c * Client ) MultiGet ( ) * MgetService {
920
+ return NewMgetService ( c )
988
921
}
989
922
990
- // Update a document .
991
- func (c * Client ) Update () * UpdateService {
992
- return NewUpdateService (c )
923
+ // Mget retrieves multiple documents in one roundtrip .
924
+ func (c * Client ) Mget () * MgetService {
925
+ return NewMgetService (c )
993
926
}
994
927
995
928
// Delete a document.
@@ -1002,29 +935,44 @@ func (c *Client) DeleteByQuery(indices ...string) *DeleteByQueryService {
1002
935
return NewDeleteByQueryService (c ).Index (indices ... )
1003
936
}
1004
937
1005
- // Get a document.
1006
- func (c * Client ) Get () * GetService {
1007
- return NewGetService (c )
938
+ // Update a document.
939
+ func (c * Client ) Update () * UpdateService {
940
+ return NewUpdateService (c )
1008
941
}
1009
942
1010
- // MultiGet retrieves multiple documents in one roundtrip .
1011
- func (c * Client ) MultiGet () * MultiGetService {
1012
- return NewMultiGetService (c )
943
+ // Bulk is the entry point to mass insert/update/delete documents .
944
+ func (c * Client ) Bulk () * BulkService {
945
+ return NewBulkService (c )
1013
946
}
1014
947
1015
- // Exists checks if a document exists.
1016
- func (c * Client ) Exists () * ExistsService {
1017
- return NewExistsService (c )
948
+ // TODO Term Vectors
949
+ // TODO Multi termvectors API
950
+
951
+ // -- Search APIs --
952
+
953
+ // Search is the entry point for searches.
954
+ func (c * Client ) Search (indices ... string ) * SearchService {
955
+ return NewSearchService (c ).Index (indices ... )
956
+ }
957
+
958
+ // Suggest returns a service to return suggestions.
959
+ func (c * Client ) Suggest (indices ... string ) * SuggestService {
960
+ return NewSuggestService (c ).Index (indices ... )
961
+ }
962
+
963
+ // MultiSearch is the entry point for multi searches.
964
+ func (c * Client ) MultiSearch () * MultiSearchService {
965
+ return NewMultiSearchService (c )
1018
966
}
1019
967
1020
968
// Count documents.
1021
969
func (c * Client ) Count (indices ... string ) * CountService {
1022
970
return NewCountService (c ).Index (indices ... )
1023
971
}
1024
972
1025
- // Search is the entry point for searches .
1026
- func (c * Client ) Search ( indices ... string ) * SearchService {
1027
- return NewSearchService (c ).Index (indices ... )
973
+ // Explain computes a score explanation for a query and a specific document .
974
+ func (c * Client ) Explain ( index , typ , id string ) * ExplainService {
975
+ return NewExplainService (c ).Index (index ). Type ( typ ). Id ( id )
1028
976
}
1029
977
1030
978
// Percolate allows to send a document and return matching queries.
@@ -1033,14 +981,15 @@ func (c *Client) Percolate() *PercolateService {
1033
981
return NewPercolateService (c )
1034
982
}
1035
983
1036
- // MultiSearch is the entry point for multi searches.
1037
- func (c * Client ) MultiSearch () * MultiSearchService {
1038
- return NewMultiSearchService (c )
1039
- }
984
+ // TODO Search Template
985
+ // TODO Search Shards API
986
+ // TODO Search Exists API
987
+ // TODO Validate API
988
+ // TODO Field Stats API
1040
989
1041
- // Suggest returns a service to return suggestions .
1042
- func (c * Client ) Suggest ( indices ... string ) * SuggestService {
1043
- return NewSuggestService ( c ). Index ( indices ... )
990
+ // Exists checks if a document exists .
991
+ func (c * Client ) Exists ( ) * ExistsService {
992
+ return NewExistsService ( c )
1044
993
}
1045
994
1046
995
// Scan through documents. Use this to iterate inside a server process
@@ -1061,6 +1010,55 @@ func (c *Client) ClearScroll(scrollIds ...string) *ClearScrollService {
1061
1010
return NewClearScrollService (c ).ScrollId (scrollIds ... )
1062
1011
}
1063
1012
1013
+ // -- Indices APIs --
1014
+
1015
+ // CreateIndex returns a service to create a new index.
1016
+ func (c * Client ) CreateIndex (name string ) * IndicesCreateService {
1017
+ return NewIndicesCreateService (c ).Index (name )
1018
+ }
1019
+
1020
+ // DeleteIndex returns a service to delete an index.
1021
+ func (c * Client ) DeleteIndex (indices ... string ) * IndicesDeleteService {
1022
+ return NewIndicesDeleteService (c ).Index (indices )
1023
+ }
1024
+
1025
+ // IndexExists allows to check if an index exists.
1026
+ func (c * Client ) IndexExists (indices ... string ) * IndicesExistsService {
1027
+ return NewIndicesExistsService (c ).Index (indices )
1028
+ }
1029
+
1030
+ // TypeExists allows to check if one or more types exist in one or more indices.
1031
+ func (c * Client ) TypeExists () * IndicesExistsTypeService {
1032
+ return NewIndicesExistsTypeService (c )
1033
+ }
1034
+
1035
+ // IndexStats provides statistics on different operations happining
1036
+ // in one or more indices.
1037
+ func (c * Client ) IndexStats (indices ... string ) * IndicesStatsService {
1038
+ return NewIndicesStatsService (c ).Index (indices ... )
1039
+ }
1040
+
1041
+ // OpenIndex opens an index.
1042
+ func (c * Client ) OpenIndex (name string ) * IndicesOpenService {
1043
+ return NewIndicesOpenService (c ).Index (name )
1044
+ }
1045
+
1046
+ // CloseIndex closes an index.
1047
+ func (c * Client ) CloseIndex (name string ) * IndicesCloseService {
1048
+ return NewIndicesCloseService (c ).Index (name )
1049
+ }
1050
+
1051
+ // IndexGet retrieves information about one or more indices.
1052
+ // IndexGet is only available for Elasticsearch 1.4 or later.
1053
+ func (c * Client ) IndexGet (indices ... string ) * IndicesGetService {
1054
+ return NewIndicesGetService (c ).Index (indices ... )
1055
+ }
1056
+
1057
+ // IndexGetSettings retrieves settings about one or more indices.
1058
+ func (c * Client ) IndexGetSettings (indices ... string ) * IndicesGetSettingsService {
1059
+ return NewIndicesGetSettingsService (c ).Index (indices ... )
1060
+ }
1061
+
1064
1062
// Optimize asks Elasticsearch to optimize one or more indices.
1065
1063
func (c * Client ) Optimize (indices ... string ) * OptimizeService {
1066
1064
return NewOptimizeService (c ).Index (indices ... )
@@ -1073,18 +1071,8 @@ func (c *Client) Refresh(indices ...string) *RefreshService {
1073
1071
1074
1072
// Flush asks Elasticsearch to free memory from the index and
1075
1073
// flush data to disk.
1076
- func (c * Client ) Flush (indices ... string ) * FlushService {
1077
- return NewFlushService (c ).Index (indices ... )
1078
- }
1079
-
1080
- // Explain computes a score explanation for a query and a specific document.
1081
- func (c * Client ) Explain (index , typ , id string ) * ExplainService {
1082
- return NewExplainService (c ).Index (index ).Type (typ ).Id (id )
1083
- }
1084
-
1085
- // Bulk is the entry point to mass insert/update/delete documents.
1086
- func (c * Client ) Bulk () * BulkService {
1087
- return NewBulkService (c )
1074
+ func (c * Client ) Flush (indices ... string ) * IndicesFlushService {
1075
+ return NewIndicesFlushService (c ).Index (indices ... )
1088
1076
}
1089
1077
1090
1078
// Alias enables the caller to add and/or remove aliases.
@@ -1149,6 +1137,25 @@ func (c *Client) PutMapping() *PutMappingService {
1149
1137
return NewPutMappingService (c )
1150
1138
}
1151
1139
1140
+ // -- cat APIs --
1141
+
1142
+ // TODO cat aliases
1143
+ // TODO cat allocation
1144
+ // TODO cat count
1145
+ // TODO cat fielddata
1146
+ // TODO cat health
1147
+ // TODO cat indices
1148
+ // TODO cat master
1149
+ // TODO cat nodes
1150
+ // TODO cat pending tasks
1151
+ // TODO cat plugins
1152
+ // TODO cat recovery
1153
+ // TODO cat thread pool
1154
+ // TODO cat shards
1155
+ // TODO cat segments
1156
+
1157
+ // -- Cluster APIs --
1158
+
1152
1159
// ClusterHealth retrieves the health of the cluster.
1153
1160
func (c * Client ) ClusterHealth () * ClusterHealthService {
1154
1161
return NewClusterHealthService (c )
@@ -1169,6 +1176,58 @@ func (c *Client) NodesInfo() *NodesInfoService {
1169
1176
return NewNodesInfoService (c )
1170
1177
}
1171
1178
1179
+ // TODO Pending cluster tasks
1180
+ // TODO Cluster Reroute
1181
+ // TODO Cluster Update Settings
1182
+ // TODO Nodes Stats
1183
+ // TODO Nodes hot_threads
1184
+
1185
+ // -- Snapshot and Restore --
1186
+
1187
+ // TODO Snapshot Create
1188
+ // TODO Snapshot Create Repository
1189
+ // TODO Snapshot Delete
1190
+ // TODO Snapshot Delete Repository
1191
+ // TODO Snapshot Get
1192
+ // TODO Snapshot Get Repository
1193
+ // TODO Snapshot Restore
1194
+ // TODO Snapshot Status
1195
+ // TODO Snapshot Verify Repository
1196
+
1197
+ // -- Helpers and shortcuts --
1198
+
1199
+ // ElasticsearchVersion returns the version number of Elasticsearch
1200
+ // running on the given URL.
1201
+ func (c * Client ) ElasticsearchVersion (url string ) (string , error ) {
1202
+ res , _ , err := c .Ping (url ).Do ()
1203
+ if err != nil {
1204
+ return "" , err
1205
+ }
1206
+ return res .Version .Number , nil
1207
+ }
1208
+
1209
+ // IndexNames returns the names of all indices in the cluster.
1210
+ func (c * Client ) IndexNames () ([]string , error ) {
1211
+ res , err := c .IndexGetSettings ().Index ("_all" ).Do ()
1212
+ if err != nil {
1213
+ return nil , err
1214
+ }
1215
+ var names []string
1216
+ for name , _ := range res {
1217
+ names = append (names , name )
1218
+ }
1219
+ return names , nil
1220
+ }
1221
+
1222
+ // Ping checks if a given node in a cluster exists and (optionally)
1223
+ // returns some basic information about the Elasticsearch server,
1224
+ // e.g. the Elasticsearch version number.
1225
+ //
1226
+ // Notice that you need to specify a URL here explicitly.
1227
+ func (c * Client ) Ping (url string ) * PingService {
1228
+ return NewPingService (c ).URL (url )
1229
+ }
1230
+
1172
1231
// Reindex returns a service that will reindex documents from a source
1173
1232
// index into a target index. See
1174
1233
// http://www.elastic.co/guide/en/elasticsearch/guide/current/reindex.html
0 commit comments